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