[TASK] Make current persistence replaceable
[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 * Schedules a modified object for persistence.
57 *
58 * @param object $object The modified object
59 * @return void
60 * @api
61 */
62 public function update($object);
63
64 /**
65 * Returns all objects of this repository.
66 *
67 * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface The query result
68 * @api
69 */
70 public function findAll();
71
72 /**
73 * Counts all objects of this repository
74 *
75 * @return integer
76 * @api
77 */
78 public function countAll();
79
80 /**
81 * Removes all objects of this repository as if remove() was called for
82 * all of them.
83 *
84 * @return void
85 * @api
86 */
87 public function removeAll();
88
89 /**
90 * Finds an object matching the given identifier.
91 *
92 * @param mixed $identifier The identifier of the object to find
93 * @return object The matching object if found, otherwise NULL
94 * @api
95 */
96 public function findByIdentifier($identifier);
97
98 /**
99 * Sets the property names to order results by. Expected like this:
100 * array(
101 * 'foo' => \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING,
102 * 'bar' => \TYPO3\Flow\Persistence\QueryInterface::ORDER_DESCENDING
103 * )
104 *
105 * @param array $defaultOrderings The property names to order by by default
106 * @return void
107 * @api
108 */
109 public function setDefaultOrderings(array $defaultOrderings);
110
111 /**
112 * Magic call method for repository methods.
113 *
114 * Provides three methods
115 * - findBy<PropertyName>($value, $caseSensitive = TRUE)
116 * - findOneBy<PropertyName>($value, $caseSensitive = TRUE)
117 * - countBy<PropertyName>($value, $caseSensitive = TRUE)
118 *
119 * @param string $method Name of the method
120 * @param array $arguments The arguments
121 * @return mixed The result of the repository method
122 * @api
123 */
124 public function __call($method, $arguments);
125
126 /**
127 * Returns a query for objects of this repository
128 *
129 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
130 * @api
131 */
132 public function createQuery();
133
134 /**
135 * If set in an implementation overrides automatic detection of the
136 * entity class name being managed by the repository.
137 *
138 * @var string
139 * @api
140 */
141 const ENTITY_CLASSNAME = NULL;
142
143 /**
144 * Returns the object type this repository is managing.
145 *
146 * @return string
147 * @api
148 */
149 public function getEntityClassName();
150 }
151
152 ?>