diff --git a/Classes/Domain/Repository/Traits/StoragePageAgnosticTrait.php b/Classes/Domain/Repository/Traits/StoragePageAgnosticTrait.php index 4f36b25..908247e 100644 --- a/Classes/Domain/Repository/Traits/StoragePageAgnosticTrait.php +++ b/Classes/Domain/Repository/Traits/StoragePageAgnosticTrait.php @@ -14,10 +14,20 @@ use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface; */ trait StoragePageAgnosticTrait { + /** + * @var QuerySettingsInterface + */ + private $querySettings; + + public function injectQuerySettings(QuerySettingsInterface $querySettings): void + { + $this->querySettings = $querySettings; + } + public function initializeObject(): void { - /** @var QuerySettingsInterface $querySettings */ - $querySettings = $this->objectManager->get(QuerySettingsInterface::class); + $querySettings = clone $this->querySettings; + $querySettings->setRespectStoragePage(false); $this->setDefaultQuerySettings($querySettings); } diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 0000000..3d09fc9 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,9 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + TTN\Tea\: + resource: '../Classes/*' + exclude: '../Classes/Domain/Model/*' diff --git a/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php b/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php index 39f94d0..d870705 100644 --- a/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php +++ b/Tests/Functional/Domain/Repository/Product/TeaRepositoryTest.php @@ -6,6 +6,7 @@ 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; @@ -38,9 +39,15 @@ class TeaRepositoryTest extends FunctionalTestCase $this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); - /** @var ObjectManager $objectManager */ - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $this->subject = $objectManager->get(TeaRepository::class); + /** @var Typo3Version $versionInformation */ + $versionInformation = GeneralUtility::makeInstance(Typo3Version::class); + if ($versionInformation->getMajorVersion() >= 11) { + $this->subject = $this->getContainer()->get(TeaRepository::class); + } else { + /** @var ObjectManager $objectManager */ + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + $this->subject = $objectManager->get(TeaRepository::class); + } } /**