[+BUGFIX] (Persistence) Make Typo3QuerySettings exchangeable
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / QueryFactory.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * The QueryFactory used to create queries against the storage backend
27 *
28 * @package Extbase
29 * @subpackage Persistence
30 * @version $Id$
31 */
32 class Tx_Extbase_Persistence_QueryFactory implements Tx_Extbase_Persistence_QueryFactoryInterface, t3lib_Singleton {
33
34 /**
35 * @var Tx_Extbase_Object_ObjectManagerInterface
36 */
37 protected $objectManager;
38
39 /**
40 * @var Tx_Extbase_Configuration_ConfigurationManagerInterface
41 */
42 protected $configurationManager;
43
44 /**
45 * @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
46 * @return void
47 * @author Sebastian Kurf├╝rst <sebastian@typo3.org>
48 */
49 public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
50 $this->objectManager = $objectManager;
51 }
52
53 /**
54 * @param Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager
55 * @return void
56 */
57 public function injectConfigurationManager(Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager) {
58 $this->configurationManager = $configurationManager;
59 }
60
61 /**
62 * Creates a query object working on the given class name
63 *
64 * @param string $className The class name
65 * @return Tx_Extbase_Persistence_QueryInterface
66 */
67 public function create($className) {
68 $query = $this->objectManager->create('Tx_Extbase_Persistence_QueryInterface', $className);
69 $querySettings = $this->objectManager->create('Tx_Extbase_Persistence_QuerySettingsInterface');
70 $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
71 $querySettings->setStoragePageIds(t3lib_div::intExplode(',', $frameworkConfiguration['persistence']['storagePid']));
72 $query->setQuerySettings($querySettings);
73
74 return $query;
75 }
76 }
77 ?>