TYPO3 CMS  TYPO3_7-6
QueryFactory.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $objectManager;
26 
31 
35  protected $dataMapper;
36 
40  public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
41  {
42  $this->objectManager = $objectManager;
43  }
44 
49  {
50  $this->configurationManager = $configurationManager;
51  }
52 
56  public function injectDataMapper(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper)
57  {
58  $this->dataMapper = $dataMapper;
59  }
60 
68  public function create($className)
69  {
70  $query = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class, $className);
71  $querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface::class);
72 
73  $dataMap = $this->dataMapper->getDataMap($className);
74  if ($dataMap->getIsStatic() || $dataMap->getRootLevel()) {
75  $querySettings->setRespectStoragePage(false);
76  }
77 
78  $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
79  $querySettings->setStoragePageIds(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $frameworkConfiguration['persistence']['storagePid']));
80  if ($querySettings instanceof Typo3QuerySettings) {
81  $querySettings->useQueryCache($frameworkConfiguration['persistence']['useQueryCache']);
82  }
83  $query->setQuerySettings($querySettings);
84  return $query;
85  }
86 }
injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
static intExplode($delimiter, $string, $removeEmptyValues=false, $limit=0)
injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
injectDataMapper(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper)