f09700cfe70373083a2360e70c336b833bc71d75
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / RepositoryInterface.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 * Contract for a repository
18 *
19 * @api
20 */
21 interface RepositoryInterface
22 {
23 /**
24 * Adds an object to this repository.
25 *
26 * @param object $object The object to add
27 * @return void
28 * @api
29 */
30 public function add($object);
31
32 /**
33 * Removes an object from this repository.
34 *
35 * @param object $object The object to remove
36 * @return void
37 * @api
38 */
39 public function remove($object);
40
41 /**
42 * Replaces an object by another.
43 *
44 * @param object $existingObject The existing object
45 * @param object $newObject The new object
46 * @return void
47 * @api
48 */
49 public function replace($existingObject, $newObject);
50
51 /**
52 * Replaces an existing object with the same identifier by the given object
53 *
54 * @param object $modifiedObject The modified object
55 * @api
56 */
57 public function update($modifiedObject);
58
59 /**
60 * Returns all objects of this repository add()ed but not yet persisted to
61 * the storage layer.
62 *
63 * @return array An array of objects
64 */
65 public function getAddedObjects();
66
67 /**
68 * Returns an array with objects remove()d from the repository that
69 * had been persisted to the storage layer before.
70 *
71 * @return array
72 */
73 public function getRemovedObjects();
74
75 /**
76 * Returns all objects of this repository.
77 *
78 * @return array An array of objects, empty if no objects found
79 * @api
80 */
81 public function findAll();
82
83 /**
84 * Returns the total number objects of this repository.
85 *
86 * @return integer The object count
87 * @api
88 */
89 public function countAll();
90
91 /**
92 * Removes all objects of this repository as if remove() was called for
93 * all of them.
94 *
95 * @return void
96 * @api
97 */
98 public function removeAll();
99
100 /**
101 * Finds an object matching the given identifier.
102 *
103 * @param int $uid The identifier of the object to find
104 * @return object The matching object if found, otherwise NULL
105 * @api
106 */
107 public function findByUid($uid);
108
109 /**
110 * Sets the property names to order the result by per default.
111 * Expected like this:
112 * array(
113 * 'foo' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING,
114 * 'bar' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING
115 * )
116 *
117 * @param array $defaultOrderings The property names to order by
118 * @return void
119 * @api
120 */
121 public function setDefaultOrderings(array $defaultOrderings);
122
123 /**
124 * Sets the default query settings to be used in this repository
125 *
126 * @param \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $defaultQuerySettings The query settings to be used by default
127 * @return void
128 * @api
129 */
130 public function setDefaultQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $defaultQuerySettings);
131
132 /**
133 * Returns a query for objects of this repository
134 *
135 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
136 * @api
137 */
138 public function createQuery();
139
140 }
141
142 ?>