[!!!][TASK] Drop extbase query cache
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / QueryFactory.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic;
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
17 /**
18 * The QueryFactory used to create queries against the storage backend
19 */
20 class QueryFactory implements QueryFactoryInterface, \TYPO3\CMS\Core\SingletonInterface
21 {
22 /**
23 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
24 */
25 protected $objectManager;
26
27 /**
28 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
29 */
30 protected $configurationManager;
31
32 /**
33 * @var \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper
34 */
35 protected $dataMapper;
36
37 /**
38 * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
39 */
40 public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
41 {
42 $this->objectManager = $objectManager;
43 }
44
45 /**
46 * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
47 */
48 public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
49 {
50 $this->configurationManager = $configurationManager;
51 }
52
53 /**
54 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper
55 */
56 public function injectDataMapper(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper)
57 {
58 $this->dataMapper = $dataMapper;
59 }
60
61 /**
62 * Creates a query object working on the given class name
63 *
64 * @param string $className The class name
65 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
66 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception
67 */
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 $query->setQuerySettings($querySettings);
81 return $query;
82 }
83 }