mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-24 15:36:12 +01:00
tea/Classes/Domain/Repository/Traits/StoragePageAgnosticTrait.php
Oliver Klee a1a84a511f
[BUGFIX] Configure DI and avoid using ObjectManager in TYPO3 11LTS (#399)
`ObjectManager` is deprecated in V11.

Fixes #387
2022-03-02 02:07:25 +01:00

34 lines
847 B
PHP

<?php
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
{
/**
* @var QuerySettingsInterface
*/
private $querySettings;
public function injectQuerySettings(QuerySettingsInterface $querySettings): void
{
$this->querySettings = $querySettings;
}
public function initializeObject(): void
{
$querySettings = clone $this->querySettings;
$querySettings->setRespectStoragePage(false);
$this->setDefaultQuerySettings($querySettings);
}
}