‪TYPO3CMS  ‪main
QueryFactory.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Container\ContainerInterface;
26 
32 {
35  private ContainerInterface ‪$container;
36 
37  public function ‪__construct(
40  ContainerInterface ‪$container
41  ) {
42  $this->configurationManager = ‪$configurationManager;
43  $this->dataMapFactory = ‪$dataMapFactory;
44  $this->container = ‪$container;
45  }
46 
55  public function ‪create($className): ‪QueryInterface
56  {
57  $query = $this->container->get(QueryInterface::class);
58  $query->‪setType($className);
59 
60  $querySettings = GeneralUtility::makeInstance(QuerySettingsInterface::class);
61 
62  $dataMap = $this->dataMapFactory->buildDataMap($className);
63  if ($dataMap->getIsStatic() || $dataMap->getRootLevel()) {
64  $querySettings->setRespectStoragePage(false);
65  }
66 
67  $frameworkConfiguration = $this->configurationManager->getConfiguration(‪ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
68  $querySettings->setStoragePageIds(‪GeneralUtility::intExplode(',', (string)($frameworkConfiguration['persistence']['storagePid'] ?? '')));
69  $query->setQuerySettings($querySettings);
70  return $query;
71  }
72 }
‪TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory
Definition: QueryFactory.php:32
‪TYPO3\CMS\Extbase\Persistence\QueryInterface
Definition: QueryInterface.php:30
‪TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory\$dataMapFactory
‪DataMapFactory $dataMapFactory
Definition: QueryFactory.php:34
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:28
‪TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory\$configurationManager
‪ConfigurationManagerInterface $configurationManager
Definition: QueryFactory.php:33
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK
‪const CONFIGURATION_TYPE_FRAMEWORK
Definition: ConfigurationManagerInterface.php:29
‪TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory
Definition: DataMapFactory.php:34
‪TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory\__construct
‪__construct(ConfigurationManagerInterface $configurationManager, DataMapFactory $dataMapFactory, ContainerInterface $container)
Definition: QueryFactory.php:37
‪TYPO3\CMS\Extbase\Persistence\Generic\QueryFactoryInterface
Definition: QueryFactoryInterface.php:22
‪TYPO3\CMS\Extbase\Persistence\Generic
Definition: Backend.php:18
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory\create
‪create($className)
Definition: QueryFactory.php:55
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Extbase\Persistence\QueryInterface\setType
‪setType(string $type)
‪TYPO3\CMS\Core\Utility\GeneralUtility\intExplode
‪static list< int > intExplode(string $delimiter, string $string, bool $removeEmptyValues=false)
Definition: GeneralUtility.php:756
‪TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory\$container
‪ContainerInterface $container
Definition: QueryFactory.php:35