[!!!][~API] Extbase (Persistence): $query->execute() now returns a plain array of...
[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 * Creates a query object working on the given class name
36 *
37 * @param string $className The class name
38 * @return Tx_Extbase_Persistence_QueryInterface
39 */
40 public function create($className) {
41 $persistenceManager = Tx_Extbase_Dispatcher::getPersistenceManager();
42
43 $dataMapper = t3lib_div::makeInstance('Tx_Extbase_Persistence_Mapper_DataMapper');
44 $dataMapper->injectIdentityMap($persistenceManager->getBackend()->getIdentityMap());
45 $dataMapper->injectSession($persistenceManager->getSession());
46 $dataMapper->injectReflectionService($persistenceManager->getBackend()->getReflectionService());
47
48 $querySettings = t3lib_div::makeInstance('Tx_Extbase_Persistence_Typo3QuerySettings');
49
50 $query = t3lib_div::makeInstance('Tx_Extbase_Persistence_Query', $className);
51 $query->injectPersistenceManager($persistenceManager);
52 $query->injectDataMapper($dataMapper);
53 $query->setQuerySettings($querySettings);
54
55 return $query;
56 }
57 }
58 ?>