[TASK] Streamline phpdoc annotations in EXT:extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / PersistenceManagerInterface.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence;
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 Extbase Persistence Manager interface
19 */
20 interface PersistenceManagerInterface
21 {
22 /**
23 * Commits new objects and changes to objects in the current persistence
24 * session into the backend
25 */
26 public function persistAll();
27
28 /**
29 * Clears the in-memory state of the persistence.
30 *
31 * Managed instances become detached, any fetches will
32 * return data directly from the persistence "backend".
33 */
34 public function clearState();
35
36 /**
37 * Checks if the given object has ever been persisted.
38 *
39 * @param object $object The object to check
40 * @return bool TRUE if the object is new, FALSE if the object exists in the repository
41 */
42 public function isNewObject($object);
43
44 // @todo realign with Flow PersistenceManager again
45
46 /**
47 * Returns the (internal) identifier for the object, if it is known to the
48 * backend. Otherwise NULL is returned.
49 *
50 * Note: this returns an identifier even if the object has not been
51 * persisted in case of AOP-managed entities. Use isNewObject() if you need
52 * to distinguish those cases.
53 *
54 * @param object $object
55 * @return mixed The identifier for the object if it is known, or NULL
56 */
57 public function getIdentifierByObject($object);
58
59 /**
60 * Returns the object with the (internal) identifier, if it is known to the
61 * backend. Otherwise NULL is returned.
62 *
63 * @param mixed $identifier
64 * @param string $objectType
65 * @param bool $useLazyLoading Set to TRUE if you want to use lazy loading for this object
66 * @return object The object for the identifier if it is known, or NULL
67 */
68 public function getObjectByIdentifier($identifier, $objectType = null, $useLazyLoading = false);
69
70 /**
71 * Returns the number of records matching the query.
72 *
73 * @param QueryInterface $query
74 * @return int
75 * @deprecated since Extbase 6.0, will be removed in Extbase 7.0. It is deprecated only in the interface to be more
76 * in sync with Flow in future and will stay in Generic Persistence.
77 */
78 public function getObjectCountByQuery(QueryInterface $query);
79
80 /**
81 * Returns the object data matching the $query.
82 *
83 * @param QueryInterface $query
84 * @return array
85 * @deprecated since Extbase 6.0, will be removed in Extbase 7.0. It is deprecated only in the interface to be more
86 * in sync with Flow in future and will stay in Generic Persistence.
87 */
88 public function getObjectDataByQuery(QueryInterface $query);
89
90 /**
91 * Registers a repository
92 *
93 * @param string $className The class name of the repository to be registered
94 * @deprecated since Extbase 6.0, will be removed in Extbase 7.0. It is deprecated only in the interface to be more
95 * in sync with Flow in future and will stay in Generic Persistence.
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 */
104 public function add($object);
105
106 /**
107 * Removes an object to the persistence.
108 *
109 * @param object $object The object to remove
110 */
111 public function remove($object);
112
113 /**
114 * Update an object in the persistence.
115 *
116 * @param object $object The modified object
117 * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
118 */
119 public function update($object);
120
121 /**
122 * Injects the Extbase settings, called by Extbase.
123 *
124 * @param array $settings
125 */
126 public function injectSettings(array $settings);
127
128 /**
129 * Converts the given object into an array containing the identity of the domain object.
130 *
131 * @param object $object The object to be converted
132 * @return array The identity array in the format array('__identity' => '...')
133 * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException if the given object is not known to the Persistence Manager
134 */
135 public function convertObjectToIdentityArray($object);
136
137 /**
138 * Recursively iterates through the given array and turns objects
139 * into arrays containing the identity of the domain object.
140 *
141 * @param array $array The array to be iterated over
142 * @return array The modified array without objects
143 * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException if array contains objects that are not known to the Persistence Manager
144 * @see convertObjectToIdentityArray()
145 */
146 public function convertObjectsToIdentityArrays(array $array);
147
148 /**
149 * Return a query object for the given type.
150 *
151 * @param string $type
152 * @return QueryInterface
153 */
154 public function createQueryForType($type);
155 }