mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-12-22 18:46:11 +01:00

[CLEANUP] Drop usages of ObjectManager whereever possible (#616)

Fixes #596
This commit is contained in:
Oliver Klee 2022-10-10 02:15:33 +02:00 committed by GitHub
parent 04ae055db2
commit 0a1a00dd22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 14 deletions

View file

@ -4,13 +4,10 @@ declare(strict_types=1);
namespace TTN\Tea\Domain\Repository\Traits;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
/**
* This trait for repositories makes the repository ignore the storage page setting when fetching models.
*
* @property ObjectManagerInterface $objectManager
*/
trait StoragePageAgnosticTrait
{

View file

@ -6,10 +6,8 @@ namespace TTN\Tea\Tests\Functional\Domain\Repository\Product;
use TTN\Tea\Domain\Model\Product\Tea;
use TTN\Tea\Domain\Repository\Product\TeaRepository;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
@ -31,13 +29,7 @@ class TeaRepositoryTest extends FunctionalTestCase
$this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
if ($versionInformation->getMajorVersion() >= 11) {
$this->subject = $this->getContainer()->get(TeaRepository::class);
} else {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->subject = $objectManager->get(TeaRepository::class);
}
$this->subject = $this->getContainer()->get(TeaRepository::class);
}
/**

View file

@ -23,8 +23,13 @@ class TeaRepositoryTest extends UnitTestCase
{
parent::setUp();
$objectManager = $this->prophesize(ObjectManagerInterface::class)->reveal();
$this->subject = new TeaRepository($objectManager);
if (\interface_exists(ObjectManagerInterface::class)) {
$objectManager = $this->prophesize(ObjectManagerInterface::class)->reveal();
$this->subject = new TeaRepository($objectManager);
} else {
// @phpstan-ignore-next-line This line is valid in TYPO3 12LTS, but PHPStan uses 11LTS.
$this->subject = new TeaRepository();
}
}
/**