f43e0b3476d131e661ba06ec3e5b5085be310e19
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / PersistenceManagerInterface.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * This class is a backport of the corresponding class of TYPO3 Flow.
8 * All credits go to the TYPO3 Flow team.
9 * All rights reserved.
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the textfile GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 /**
31 * The Extbase Persistence Manager interface
32 */
33 interface PersistenceManagerInterface {
34
35 /**
36 * Commits new objects and changes to objects in the current persistence
37 * session into the backend
38 *
39 * @return void
40 * @api
41 */
42 public function persistAll();
43
44 /**
45 * Returns the (internal) identifier for the object, if it is known to the
46 * backend. Otherwise NULL is returned.
47 *
48 * Note: this returns an identifier even if the object has not been
49 * persisted in case of AOP-managed entities. Use isNewObject() if you need
50 * to distinguish those cases.
51 *
52 * @param object $object
53 * @return mixed The identifier for the object if it is known, or NULL
54 * @api
55 */
56 public function getIdentifierByObject($object);
57
58 /**
59 * Returns the object with the (internal) identifier, if it is known to the
60 * backend. Otherwise NULL is returned.
61 *
62 * @param mixed $identifier
63 * @param string $objectType
64 * @param boolean $useLazyLoading Set to TRUE if you want to use lazy loading for this object
65 * @return object The object for the identifier if it is known, or NULL
66 * @api
67 */
68 public function getObjectByIdentifier($identifier, $objectType = NULL, $useLazyLoading = FALSE);
69
70 /**
71 * Returns the number of records matching the query.
72 *
73 * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
74 * @return integer
75 * @deprecated since Extbase 6.0, will be removed in Extbase 7.0
76 * @api
77 */
78 public function getObjectCountByQuery(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query);
79
80 /**
81 * Returns the object data matching the $query.
82 *
83 * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
84 * @return array
85 * @deprecated since Extbase 6.0, will be removed in Extbase 7.0
86 * @api
87 */
88 public function getObjectDataByQuery(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query);
89
90 /**
91 * Registers a repository
92 *
93 * @param string $className The class name of the repository to be reigistered
94 * @deprecated since Extbase 6.0, will be removed in Extbase 7.0
95 * @return void
96 */
97 public function registerRepositoryClassName($className);
98
99 /**
100 * Adds an object to the persistence.
101 *
102 * @param object $object The object to add
103 * @return void
104 * @api
105 */
106 public function add($object);
107
108 /**
109 * Removes an object to the persistence.
110 *
111 * @param object $object The object to remove
112 * @return void
113 * @api
114 */
115 public function remove($object);
116
117 /**
118 * Update an object in the persistence.
119 *
120 * @param object $object The modified object
121 * @return void
122 * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
123 * @api
124 */
125 public function update($object);
126
127 /**
128 * Injects the Extbase settings, called by Extbase.
129 *
130 * @param array $settings
131 * @return void
132 * @api
133 */
134 public function injectSettings(array $settings);
135
136 /**
137 * Initializes the persistence manager, called by Extbase.
138 *
139 * @return void
140 * @api
141 */
142 public function initialize();
143
144 /**
145 * Clears the in-memory state of the persistence.
146 *
147 * Managed instances become detached, any fetches will
148 * return data directly from the persistence "backend".
149 *
150 * @return void
151 */
152 public function clearState();
153
154 /**
155 * Checks if the given object has ever been persisted.
156 *
157 * @param object $object The object to check
158 * @return boolean TRUE if the object is new, FALSE if the object exists in the repository
159 * @api
160 */
161 public function isNewObject($object);
162
163 /**
164 * Converts the given object into an array containing the identity of the domain object.
165 *
166 * @param object $object The object to be converted
167 * @return array The identity array in the format array('__identity' => '...')
168 * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException if the given object is not known to the Persistence Manager
169 * @api
170 */
171 public function convertObjectToIdentityArray($object);
172
173 /**
174 * Recursively iterates through the given array and turns objects
175 * into arrays containing the identity of the domain object.
176 *
177 * @param array $array The array to be iterated over
178 * @return array The modified array without objects
179 * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException if array contains objects that are not known to the Persistence Manager
180 * @api
181 * @see convertObjectToIdentityArray()
182 */
183 public function convertObjectsToIdentityArrays(array $array);
184
185 /**
186 * Return a query object for the given type.
187 *
188 * @param string $type
189 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
190 * @api
191 */
192 public function createQueryForType($type);
193 }
194
195 ?>