mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-10 00:36:13 +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;
|
namespace TTN\Tea\Domain\Repository\Traits;
|
||||||
|
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
|
||||||
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
|
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This trait for repositories makes the repository ignore the storage page setting when fetching models.
|
* This trait for repositories makes the repository ignore the storage page setting when fetching models.
|
||||||
*
|
|
||||||
* @property ObjectManagerInterface $objectManager
|
|
||||||
*/
|
*/
|
||||||
trait StoragePageAgnosticTrait
|
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\Model\Product\Tea;
|
||||||
use TTN\Tea\Domain\Repository\Product\TeaRepository;
|
use TTN\Tea\Domain\Repository\Product\TeaRepository;
|
||||||
use TYPO3\CMS\Core\Information\Typo3Version;
|
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
|
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
|
||||||
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
|
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
|
||||||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
||||||
|
|
||||||
|
@ -31,13 +29,7 @@ class TeaRepositoryTest extends FunctionalTestCase
|
||||||
|
|
||||||
$this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
|
$this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
|
||||||
|
|
||||||
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
|
$this->subject = $this->getContainer()->get(TeaRepository::class);
|
||||||
if ($versionInformation->getMajorVersion() >= 11) {
|
|
||||||
$this->subject = $this->getContainer()->get(TeaRepository::class);
|
|
||||||
} else {
|
|
||||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
|
||||||
$this->subject = $objectManager->get(TeaRepository::class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,8 +23,13 @@ class TeaRepositoryTest extends UnitTestCase
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$objectManager = $this->prophesize(ObjectManagerInterface::class)->reveal();
|
if (\interface_exists(ObjectManagerInterface::class)) {
|
||||||
$this->subject = new TeaRepository($objectManager);
|
$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