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