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:
parent
04ae055db2
commit
0a1a00dd22
3 changed files with 8 additions and 14 deletions
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue