@@ -46,7 +46,7 @@ |
||
46 | 46 | * DispatcherEvent constructor. |
47 | 47 | * |
48 | 48 | * @param string $event |
49 | - * @param $appID |
|
49 | + * @param string $appID |
|
50 | 50 | * @param \OCP\IGroup[] $groups |
51 | 51 | * @since 9.0.0 |
52 | 52 | */ |
@@ -32,61 +32,61 @@ |
||
32 | 32 | */ |
33 | 33 | class ManagerEvent extends Event { |
34 | 34 | |
35 | - const EVENT_APP_ENABLE = 'OCP\App\IAppManager::enableApp'; |
|
36 | - const EVENT_APP_ENABLE_FOR_GROUPS = 'OCP\App\IAppManager::enableAppForGroups'; |
|
37 | - const EVENT_APP_DISABLE = 'OCP\App\IAppManager::disableApp'; |
|
35 | + const EVENT_APP_ENABLE = 'OCP\App\IAppManager::enableApp'; |
|
36 | + const EVENT_APP_ENABLE_FOR_GROUPS = 'OCP\App\IAppManager::enableAppForGroups'; |
|
37 | + const EVENT_APP_DISABLE = 'OCP\App\IAppManager::disableApp'; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @since 9.1.0 |
|
41 | - */ |
|
42 | - const EVENT_APP_UPDATE = 'OCP\App\IAppManager::updateApp'; |
|
39 | + /** |
|
40 | + * @since 9.1.0 |
|
41 | + */ |
|
42 | + const EVENT_APP_UPDATE = 'OCP\App\IAppManager::updateApp'; |
|
43 | 43 | |
44 | - /** @var string */ |
|
45 | - protected $event; |
|
46 | - /** @var string */ |
|
47 | - protected $appID; |
|
48 | - /** @var \OCP\IGroup[] */ |
|
49 | - protected $groups; |
|
44 | + /** @var string */ |
|
45 | + protected $event; |
|
46 | + /** @var string */ |
|
47 | + protected $appID; |
|
48 | + /** @var \OCP\IGroup[] */ |
|
49 | + protected $groups; |
|
50 | 50 | |
51 | - /** |
|
52 | - * DispatcherEvent constructor. |
|
53 | - * |
|
54 | - * @param string $event |
|
55 | - * @param $appID |
|
56 | - * @param \OCP\IGroup[] $groups |
|
57 | - * @since 9.0.0 |
|
58 | - */ |
|
59 | - public function __construct($event, $appID, array $groups = null) { |
|
60 | - $this->event = $event; |
|
61 | - $this->appID = $appID; |
|
62 | - $this->groups = $groups; |
|
63 | - } |
|
51 | + /** |
|
52 | + * DispatcherEvent constructor. |
|
53 | + * |
|
54 | + * @param string $event |
|
55 | + * @param $appID |
|
56 | + * @param \OCP\IGroup[] $groups |
|
57 | + * @since 9.0.0 |
|
58 | + */ |
|
59 | + public function __construct($event, $appID, array $groups = null) { |
|
60 | + $this->event = $event; |
|
61 | + $this->appID = $appID; |
|
62 | + $this->groups = $groups; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return string |
|
67 | - * @since 9.0.0 |
|
68 | - */ |
|
69 | - public function getEvent() { |
|
70 | - return $this->event; |
|
71 | - } |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + * @since 9.0.0 |
|
68 | + */ |
|
69 | + public function getEvent() { |
|
70 | + return $this->event; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return string |
|
75 | - * @since 9.0.0 |
|
76 | - */ |
|
77 | - public function getAppID() { |
|
78 | - return $this->appID; |
|
79 | - } |
|
73 | + /** |
|
74 | + * @return string |
|
75 | + * @since 9.0.0 |
|
76 | + */ |
|
77 | + public function getAppID() { |
|
78 | + return $this->appID; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * returns the group Ids |
|
83 | - * @return string[] |
|
84 | - * @since 9.0.0 |
|
85 | - */ |
|
86 | - public function getGroups() { |
|
87 | - return array_map(function ($group) { |
|
88 | - /** @var \OCP\IGroup $group */ |
|
89 | - return $group->getGID(); |
|
90 | - }, $this->groups); |
|
91 | - } |
|
81 | + /** |
|
82 | + * returns the group Ids |
|
83 | + * @return string[] |
|
84 | + * @since 9.0.0 |
|
85 | + */ |
|
86 | + public function getGroups() { |
|
87 | + return array_map(function ($group) { |
|
88 | + /** @var \OCP\IGroup $group */ |
|
89 | + return $group->getGID(); |
|
90 | + }, $this->groups); |
|
91 | + } |
|
92 | 92 | } |
@@ -84,7 +84,7 @@ |
||
84 | 84 | * @since 9.0.0 |
85 | 85 | */ |
86 | 86 | public function getGroups() { |
87 | - return array_map(function ($group) { |
|
87 | + return array_map(function($group) { |
|
88 | 88 | /** @var \OCP\IGroup $group */ |
89 | 89 | return $group->getGID(); |
90 | 90 | }, $this->groups); |
@@ -308,6 +308,7 @@ discard block |
||
308 | 308 | * @param array $params the parameters of the sql query |
309 | 309 | * @param int $limit the maximum number of rows |
310 | 310 | * @param int $offset from which row we want to start |
311 | + * @param string $msg |
|
311 | 312 | * @return string formatted error message string |
312 | 313 | * @since 9.1.0 |
313 | 314 | */ |
@@ -360,7 +361,7 @@ discard block |
||
360 | 361 | * Returns an db result and throws exceptions when there are more or less |
361 | 362 | * results |
362 | 363 | * @param string $sql the sql query |
363 | - * @param array $params the parameters of the sql query |
|
364 | + * @param string[] $params the parameters of the sql query |
|
364 | 365 | * @param int $limit the maximum number of rows |
365 | 366 | * @param int $offset from which row we want to start |
366 | 367 | * @throws DoesNotExistException if the item does not exist |
@@ -37,327 +37,327 @@ |
||
37 | 37 | */ |
38 | 38 | abstract class Mapper { |
39 | 39 | |
40 | - protected $tableName; |
|
41 | - protected $entityClass; |
|
42 | - protected $db; |
|
43 | - |
|
44 | - /** |
|
45 | - * @param IDBConnection $db Instance of the Db abstraction layer |
|
46 | - * @param string $tableName the name of the table. set this to allow entity |
|
47 | - * @param string $entityClass the name of the entity that the sql should be |
|
48 | - * mapped to queries without using sql |
|
49 | - * @since 7.0.0 |
|
50 | - */ |
|
51 | - public function __construct(IDBConnection $db, $tableName, $entityClass=null){ |
|
52 | - $this->db = $db; |
|
53 | - $this->tableName = '*PREFIX*' . $tableName; |
|
54 | - |
|
55 | - // if not given set the entity name to the class without the mapper part |
|
56 | - // cache it here for later use since reflection is slow |
|
57 | - if($entityClass === null) { |
|
58 | - $this->entityClass = str_replace('Mapper', '', get_class($this)); |
|
59 | - } else { |
|
60 | - $this->entityClass = $entityClass; |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @return string the table name |
|
67 | - * @since 7.0.0 |
|
68 | - */ |
|
69 | - public function getTableName(){ |
|
70 | - return $this->tableName; |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Deletes an entity from the table |
|
76 | - * @param Entity $entity the entity that should be deleted |
|
77 | - * @return Entity the deleted entity |
|
78 | - * @since 7.0.0 - return value added in 8.1.0 |
|
79 | - */ |
|
80 | - public function delete(Entity $entity){ |
|
81 | - $sql = 'DELETE FROM `' . $this->tableName . '` WHERE `id` = ?'; |
|
82 | - $stmt = $this->execute($sql, [$entity->getId()]); |
|
83 | - $stmt->closeCursor(); |
|
84 | - return $entity; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * Creates a new entry in the db from an entity |
|
90 | - * @param Entity $entity the entity that should be created |
|
91 | - * @return Entity the saved entity with the set id |
|
92 | - * @since 7.0.0 |
|
93 | - */ |
|
94 | - public function insert(Entity $entity){ |
|
95 | - // get updated fields to save, fields have to be set using a setter to |
|
96 | - // be saved |
|
97 | - $properties = $entity->getUpdatedFields(); |
|
98 | - $values = ''; |
|
99 | - $columns = ''; |
|
100 | - $params = []; |
|
101 | - |
|
102 | - // build the fields |
|
103 | - $i = 0; |
|
104 | - foreach($properties as $property => $updated) { |
|
105 | - $column = $entity->propertyToColumn($property); |
|
106 | - $getter = 'get' . ucfirst($property); |
|
107 | - |
|
108 | - $columns .= '`' . $column . '`'; |
|
109 | - $values .= '?'; |
|
110 | - |
|
111 | - // only append colon if there are more entries |
|
112 | - if($i < count($properties)-1){ |
|
113 | - $columns .= ','; |
|
114 | - $values .= ','; |
|
115 | - } |
|
116 | - |
|
117 | - $params[] = $entity->$getter(); |
|
118 | - $i++; |
|
119 | - |
|
120 | - } |
|
121 | - |
|
122 | - $sql = 'INSERT INTO `' . $this->tableName . '`(' . |
|
123 | - $columns . ') VALUES(' . $values . ')'; |
|
124 | - |
|
125 | - $stmt = $this->execute($sql, $params); |
|
126 | - |
|
127 | - $entity->setId((int) $this->db->lastInsertId($this->tableName)); |
|
128 | - |
|
129 | - $stmt->closeCursor(); |
|
130 | - |
|
131 | - return $entity; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * Updates an entry in the db from an entity |
|
138 | - * @throws \InvalidArgumentException if entity has no id |
|
139 | - * @param Entity $entity the entity that should be created |
|
140 | - * @return Entity the saved entity with the set id |
|
141 | - * @since 7.0.0 - return value was added in 8.0.0 |
|
142 | - */ |
|
143 | - public function update(Entity $entity){ |
|
144 | - // if entity wasn't changed it makes no sense to run a db query |
|
145 | - $properties = $entity->getUpdatedFields(); |
|
146 | - if(count($properties) === 0) { |
|
147 | - return $entity; |
|
148 | - } |
|
149 | - |
|
150 | - // entity needs an id |
|
151 | - $id = $entity->getId(); |
|
152 | - if($id === null){ |
|
153 | - throw new \InvalidArgumentException( |
|
154 | - 'Entity which should be updated has no id'); |
|
155 | - } |
|
156 | - |
|
157 | - // get updated fields to save, fields have to be set using a setter to |
|
158 | - // be saved |
|
159 | - // do not update the id field |
|
160 | - unset($properties['id']); |
|
161 | - |
|
162 | - $columns = ''; |
|
163 | - $params = []; |
|
164 | - |
|
165 | - // build the fields |
|
166 | - $i = 0; |
|
167 | - foreach($properties as $property => $updated) { |
|
168 | - |
|
169 | - $column = $entity->propertyToColumn($property); |
|
170 | - $getter = 'get' . ucfirst($property); |
|
171 | - |
|
172 | - $columns .= '`' . $column . '` = ?'; |
|
173 | - |
|
174 | - // only append colon if there are more entries |
|
175 | - if($i < count($properties)-1){ |
|
176 | - $columns .= ','; |
|
177 | - } |
|
178 | - |
|
179 | - $params[] = $entity->$getter(); |
|
180 | - $i++; |
|
181 | - } |
|
182 | - |
|
183 | - $sql = 'UPDATE `' . $this->tableName . '` SET ' . |
|
184 | - $columns . ' WHERE `id` = ?'; |
|
185 | - $params[] = $id; |
|
186 | - |
|
187 | - $stmt = $this->execute($sql, $params); |
|
188 | - $stmt->closeCursor(); |
|
189 | - |
|
190 | - return $entity; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * Checks if an array is associative |
|
195 | - * @param array $array |
|
196 | - * @return bool true if associative |
|
197 | - * @since 8.1.0 |
|
198 | - */ |
|
199 | - private function isAssocArray(array $array) { |
|
200 | - return array_values($array) !== $array; |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Returns the correct PDO constant based on the value type |
|
205 | - * @param $value |
|
206 | - * @return int PDO constant |
|
207 | - * @since 8.1.0 |
|
208 | - */ |
|
209 | - private function getPDOType($value) { |
|
210 | - switch (gettype($value)) { |
|
211 | - case 'integer': |
|
212 | - return \PDO::PARAM_INT; |
|
213 | - case 'boolean': |
|
214 | - return \PDO::PARAM_BOOL; |
|
215 | - default: |
|
216 | - return \PDO::PARAM_STR; |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * Runs an sql query |
|
223 | - * @param string $sql the prepare string |
|
224 | - * @param array $params the params which should replace the ? in the sql query |
|
225 | - * @param int $limit the maximum number of rows |
|
226 | - * @param int $offset from which row we want to start |
|
227 | - * @return \PDOStatement the database query result |
|
228 | - * @since 7.0.0 |
|
229 | - */ |
|
230 | - protected function execute($sql, array $params=[], $limit=null, $offset=null){ |
|
231 | - $query = $this->db->prepare($sql, $limit, $offset); |
|
232 | - |
|
233 | - if ($this->isAssocArray($params)) { |
|
234 | - foreach ($params as $key => $param) { |
|
235 | - $pdoConstant = $this->getPDOType($param); |
|
236 | - $query->bindValue($key, $param, $pdoConstant); |
|
237 | - } |
|
238 | - } else { |
|
239 | - $index = 1; // bindParam is 1 indexed |
|
240 | - foreach ($params as $param) { |
|
241 | - $pdoConstant = $this->getPDOType($param); |
|
242 | - $query->bindValue($index, $param, $pdoConstant); |
|
243 | - $index++; |
|
244 | - } |
|
245 | - } |
|
246 | - |
|
247 | - $result = $query->execute(); |
|
248 | - |
|
249 | - return $query; |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * Returns an db result and throws exceptions when there are more or less |
|
255 | - * results |
|
256 | - * @see findEntity |
|
257 | - * @param string $sql the sql query |
|
258 | - * @param array $params the parameters of the sql query |
|
259 | - * @param int $limit the maximum number of rows |
|
260 | - * @param int $offset from which row we want to start |
|
261 | - * @throws DoesNotExistException if the item does not exist |
|
262 | - * @throws MultipleObjectsReturnedException if more than one item exist |
|
263 | - * @return array the result as row |
|
264 | - * @since 7.0.0 |
|
265 | - */ |
|
266 | - protected function findOneQuery($sql, array $params=[], $limit=null, $offset=null){ |
|
267 | - $stmt = $this->execute($sql, $params, $limit, $offset); |
|
268 | - $row = $stmt->fetch(); |
|
269 | - |
|
270 | - if($row === false || $row === null){ |
|
271 | - $stmt->closeCursor(); |
|
272 | - $msg = $this->buildDebugMessage( |
|
273 | - 'Did expect one result but found none when executing', $sql, $params, $limit, $offset |
|
274 | - ); |
|
275 | - throw new DoesNotExistException($msg); |
|
276 | - } |
|
277 | - $row2 = $stmt->fetch(); |
|
278 | - $stmt->closeCursor(); |
|
279 | - //MDB2 returns null, PDO and doctrine false when no row is available |
|
280 | - if( ! ($row2 === false || $row2 === null )) { |
|
281 | - $msg = $this->buildDebugMessage( |
|
282 | - 'Did not expect more than one result when executing', $sql, $params, $limit, $offset |
|
283 | - ); |
|
284 | - throw new MultipleObjectsReturnedException($msg); |
|
285 | - } else { |
|
286 | - return $row; |
|
287 | - } |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * Builds an error message by prepending the $msg to an error message which |
|
292 | - * has the parameters |
|
293 | - * @see findEntity |
|
294 | - * @param string $sql the sql query |
|
295 | - * @param array $params the parameters of the sql query |
|
296 | - * @param int $limit the maximum number of rows |
|
297 | - * @param int $offset from which row we want to start |
|
298 | - * @return string formatted error message string |
|
299 | - * @since 9.1.0 |
|
300 | - */ |
|
301 | - private function buildDebugMessage($msg, $sql, array $params=[], $limit=null, $offset=null) { |
|
302 | - return $msg . |
|
303 | - ': query "' . $sql . '"; ' . |
|
304 | - 'parameters ' . print_r($params, true) . '; ' . |
|
305 | - 'limit "' . $limit . '"; '. |
|
306 | - 'offset "' . $offset . '"'; |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * Creates an entity from a row. Automatically determines the entity class |
|
312 | - * from the current mapper name (MyEntityMapper -> MyEntity) |
|
313 | - * @param array $row the row which should be converted to an entity |
|
314 | - * @return Entity the entity |
|
315 | - * @since 7.0.0 |
|
316 | - */ |
|
317 | - protected function mapRowToEntity($row) { |
|
318 | - return call_user_func($this->entityClass .'::fromRow', $row); |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - /** |
|
323 | - * Runs a sql query and returns an array of entities |
|
324 | - * @param string $sql the prepare string |
|
325 | - * @param array $params the params which should replace the ? in the sql query |
|
326 | - * @param int $limit the maximum number of rows |
|
327 | - * @param int $offset from which row we want to start |
|
328 | - * @return array all fetched entities |
|
329 | - * @since 7.0.0 |
|
330 | - */ |
|
331 | - protected function findEntities($sql, array $params=[], $limit=null, $offset=null) { |
|
332 | - $stmt = $this->execute($sql, $params, $limit, $offset); |
|
333 | - |
|
334 | - $entities = []; |
|
335 | - |
|
336 | - while($row = $stmt->fetch()){ |
|
337 | - $entities[] = $this->mapRowToEntity($row); |
|
338 | - } |
|
339 | - |
|
340 | - $stmt->closeCursor(); |
|
341 | - |
|
342 | - return $entities; |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * Returns an db result and throws exceptions when there are more or less |
|
348 | - * results |
|
349 | - * @param string $sql the sql query |
|
350 | - * @param array $params the parameters of the sql query |
|
351 | - * @param int $limit the maximum number of rows |
|
352 | - * @param int $offset from which row we want to start |
|
353 | - * @throws DoesNotExistException if the item does not exist |
|
354 | - * @throws MultipleObjectsReturnedException if more than one item exist |
|
355 | - * @return Entity the entity |
|
356 | - * @since 7.0.0 |
|
357 | - */ |
|
358 | - protected function findEntity($sql, array $params=[], $limit=null, $offset=null){ |
|
359 | - return $this->mapRowToEntity($this->findOneQuery($sql, $params, $limit, $offset)); |
|
360 | - } |
|
40 | + protected $tableName; |
|
41 | + protected $entityClass; |
|
42 | + protected $db; |
|
43 | + |
|
44 | + /** |
|
45 | + * @param IDBConnection $db Instance of the Db abstraction layer |
|
46 | + * @param string $tableName the name of the table. set this to allow entity |
|
47 | + * @param string $entityClass the name of the entity that the sql should be |
|
48 | + * mapped to queries without using sql |
|
49 | + * @since 7.0.0 |
|
50 | + */ |
|
51 | + public function __construct(IDBConnection $db, $tableName, $entityClass=null){ |
|
52 | + $this->db = $db; |
|
53 | + $this->tableName = '*PREFIX*' . $tableName; |
|
54 | + |
|
55 | + // if not given set the entity name to the class without the mapper part |
|
56 | + // cache it here for later use since reflection is slow |
|
57 | + if($entityClass === null) { |
|
58 | + $this->entityClass = str_replace('Mapper', '', get_class($this)); |
|
59 | + } else { |
|
60 | + $this->entityClass = $entityClass; |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @return string the table name |
|
67 | + * @since 7.0.0 |
|
68 | + */ |
|
69 | + public function getTableName(){ |
|
70 | + return $this->tableName; |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Deletes an entity from the table |
|
76 | + * @param Entity $entity the entity that should be deleted |
|
77 | + * @return Entity the deleted entity |
|
78 | + * @since 7.0.0 - return value added in 8.1.0 |
|
79 | + */ |
|
80 | + public function delete(Entity $entity){ |
|
81 | + $sql = 'DELETE FROM `' . $this->tableName . '` WHERE `id` = ?'; |
|
82 | + $stmt = $this->execute($sql, [$entity->getId()]); |
|
83 | + $stmt->closeCursor(); |
|
84 | + return $entity; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * Creates a new entry in the db from an entity |
|
90 | + * @param Entity $entity the entity that should be created |
|
91 | + * @return Entity the saved entity with the set id |
|
92 | + * @since 7.0.0 |
|
93 | + */ |
|
94 | + public function insert(Entity $entity){ |
|
95 | + // get updated fields to save, fields have to be set using a setter to |
|
96 | + // be saved |
|
97 | + $properties = $entity->getUpdatedFields(); |
|
98 | + $values = ''; |
|
99 | + $columns = ''; |
|
100 | + $params = []; |
|
101 | + |
|
102 | + // build the fields |
|
103 | + $i = 0; |
|
104 | + foreach($properties as $property => $updated) { |
|
105 | + $column = $entity->propertyToColumn($property); |
|
106 | + $getter = 'get' . ucfirst($property); |
|
107 | + |
|
108 | + $columns .= '`' . $column . '`'; |
|
109 | + $values .= '?'; |
|
110 | + |
|
111 | + // only append colon if there are more entries |
|
112 | + if($i < count($properties)-1){ |
|
113 | + $columns .= ','; |
|
114 | + $values .= ','; |
|
115 | + } |
|
116 | + |
|
117 | + $params[] = $entity->$getter(); |
|
118 | + $i++; |
|
119 | + |
|
120 | + } |
|
121 | + |
|
122 | + $sql = 'INSERT INTO `' . $this->tableName . '`(' . |
|
123 | + $columns . ') VALUES(' . $values . ')'; |
|
124 | + |
|
125 | + $stmt = $this->execute($sql, $params); |
|
126 | + |
|
127 | + $entity->setId((int) $this->db->lastInsertId($this->tableName)); |
|
128 | + |
|
129 | + $stmt->closeCursor(); |
|
130 | + |
|
131 | + return $entity; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * Updates an entry in the db from an entity |
|
138 | + * @throws \InvalidArgumentException if entity has no id |
|
139 | + * @param Entity $entity the entity that should be created |
|
140 | + * @return Entity the saved entity with the set id |
|
141 | + * @since 7.0.0 - return value was added in 8.0.0 |
|
142 | + */ |
|
143 | + public function update(Entity $entity){ |
|
144 | + // if entity wasn't changed it makes no sense to run a db query |
|
145 | + $properties = $entity->getUpdatedFields(); |
|
146 | + if(count($properties) === 0) { |
|
147 | + return $entity; |
|
148 | + } |
|
149 | + |
|
150 | + // entity needs an id |
|
151 | + $id = $entity->getId(); |
|
152 | + if($id === null){ |
|
153 | + throw new \InvalidArgumentException( |
|
154 | + 'Entity which should be updated has no id'); |
|
155 | + } |
|
156 | + |
|
157 | + // get updated fields to save, fields have to be set using a setter to |
|
158 | + // be saved |
|
159 | + // do not update the id field |
|
160 | + unset($properties['id']); |
|
161 | + |
|
162 | + $columns = ''; |
|
163 | + $params = []; |
|
164 | + |
|
165 | + // build the fields |
|
166 | + $i = 0; |
|
167 | + foreach($properties as $property => $updated) { |
|
168 | + |
|
169 | + $column = $entity->propertyToColumn($property); |
|
170 | + $getter = 'get' . ucfirst($property); |
|
171 | + |
|
172 | + $columns .= '`' . $column . '` = ?'; |
|
173 | + |
|
174 | + // only append colon if there are more entries |
|
175 | + if($i < count($properties)-1){ |
|
176 | + $columns .= ','; |
|
177 | + } |
|
178 | + |
|
179 | + $params[] = $entity->$getter(); |
|
180 | + $i++; |
|
181 | + } |
|
182 | + |
|
183 | + $sql = 'UPDATE `' . $this->tableName . '` SET ' . |
|
184 | + $columns . ' WHERE `id` = ?'; |
|
185 | + $params[] = $id; |
|
186 | + |
|
187 | + $stmt = $this->execute($sql, $params); |
|
188 | + $stmt->closeCursor(); |
|
189 | + |
|
190 | + return $entity; |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * Checks if an array is associative |
|
195 | + * @param array $array |
|
196 | + * @return bool true if associative |
|
197 | + * @since 8.1.0 |
|
198 | + */ |
|
199 | + private function isAssocArray(array $array) { |
|
200 | + return array_values($array) !== $array; |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Returns the correct PDO constant based on the value type |
|
205 | + * @param $value |
|
206 | + * @return int PDO constant |
|
207 | + * @since 8.1.0 |
|
208 | + */ |
|
209 | + private function getPDOType($value) { |
|
210 | + switch (gettype($value)) { |
|
211 | + case 'integer': |
|
212 | + return \PDO::PARAM_INT; |
|
213 | + case 'boolean': |
|
214 | + return \PDO::PARAM_BOOL; |
|
215 | + default: |
|
216 | + return \PDO::PARAM_STR; |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * Runs an sql query |
|
223 | + * @param string $sql the prepare string |
|
224 | + * @param array $params the params which should replace the ? in the sql query |
|
225 | + * @param int $limit the maximum number of rows |
|
226 | + * @param int $offset from which row we want to start |
|
227 | + * @return \PDOStatement the database query result |
|
228 | + * @since 7.0.0 |
|
229 | + */ |
|
230 | + protected function execute($sql, array $params=[], $limit=null, $offset=null){ |
|
231 | + $query = $this->db->prepare($sql, $limit, $offset); |
|
232 | + |
|
233 | + if ($this->isAssocArray($params)) { |
|
234 | + foreach ($params as $key => $param) { |
|
235 | + $pdoConstant = $this->getPDOType($param); |
|
236 | + $query->bindValue($key, $param, $pdoConstant); |
|
237 | + } |
|
238 | + } else { |
|
239 | + $index = 1; // bindParam is 1 indexed |
|
240 | + foreach ($params as $param) { |
|
241 | + $pdoConstant = $this->getPDOType($param); |
|
242 | + $query->bindValue($index, $param, $pdoConstant); |
|
243 | + $index++; |
|
244 | + } |
|
245 | + } |
|
246 | + |
|
247 | + $result = $query->execute(); |
|
248 | + |
|
249 | + return $query; |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * Returns an db result and throws exceptions when there are more or less |
|
255 | + * results |
|
256 | + * @see findEntity |
|
257 | + * @param string $sql the sql query |
|
258 | + * @param array $params the parameters of the sql query |
|
259 | + * @param int $limit the maximum number of rows |
|
260 | + * @param int $offset from which row we want to start |
|
261 | + * @throws DoesNotExistException if the item does not exist |
|
262 | + * @throws MultipleObjectsReturnedException if more than one item exist |
|
263 | + * @return array the result as row |
|
264 | + * @since 7.0.0 |
|
265 | + */ |
|
266 | + protected function findOneQuery($sql, array $params=[], $limit=null, $offset=null){ |
|
267 | + $stmt = $this->execute($sql, $params, $limit, $offset); |
|
268 | + $row = $stmt->fetch(); |
|
269 | + |
|
270 | + if($row === false || $row === null){ |
|
271 | + $stmt->closeCursor(); |
|
272 | + $msg = $this->buildDebugMessage( |
|
273 | + 'Did expect one result but found none when executing', $sql, $params, $limit, $offset |
|
274 | + ); |
|
275 | + throw new DoesNotExistException($msg); |
|
276 | + } |
|
277 | + $row2 = $stmt->fetch(); |
|
278 | + $stmt->closeCursor(); |
|
279 | + //MDB2 returns null, PDO and doctrine false when no row is available |
|
280 | + if( ! ($row2 === false || $row2 === null )) { |
|
281 | + $msg = $this->buildDebugMessage( |
|
282 | + 'Did not expect more than one result when executing', $sql, $params, $limit, $offset |
|
283 | + ); |
|
284 | + throw new MultipleObjectsReturnedException($msg); |
|
285 | + } else { |
|
286 | + return $row; |
|
287 | + } |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * Builds an error message by prepending the $msg to an error message which |
|
292 | + * has the parameters |
|
293 | + * @see findEntity |
|
294 | + * @param string $sql the sql query |
|
295 | + * @param array $params the parameters of the sql query |
|
296 | + * @param int $limit the maximum number of rows |
|
297 | + * @param int $offset from which row we want to start |
|
298 | + * @return string formatted error message string |
|
299 | + * @since 9.1.0 |
|
300 | + */ |
|
301 | + private function buildDebugMessage($msg, $sql, array $params=[], $limit=null, $offset=null) { |
|
302 | + return $msg . |
|
303 | + ': query "' . $sql . '"; ' . |
|
304 | + 'parameters ' . print_r($params, true) . '; ' . |
|
305 | + 'limit "' . $limit . '"; '. |
|
306 | + 'offset "' . $offset . '"'; |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * Creates an entity from a row. Automatically determines the entity class |
|
312 | + * from the current mapper name (MyEntityMapper -> MyEntity) |
|
313 | + * @param array $row the row which should be converted to an entity |
|
314 | + * @return Entity the entity |
|
315 | + * @since 7.0.0 |
|
316 | + */ |
|
317 | + protected function mapRowToEntity($row) { |
|
318 | + return call_user_func($this->entityClass .'::fromRow', $row); |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + /** |
|
323 | + * Runs a sql query and returns an array of entities |
|
324 | + * @param string $sql the prepare string |
|
325 | + * @param array $params the params which should replace the ? in the sql query |
|
326 | + * @param int $limit the maximum number of rows |
|
327 | + * @param int $offset from which row we want to start |
|
328 | + * @return array all fetched entities |
|
329 | + * @since 7.0.0 |
|
330 | + */ |
|
331 | + protected function findEntities($sql, array $params=[], $limit=null, $offset=null) { |
|
332 | + $stmt = $this->execute($sql, $params, $limit, $offset); |
|
333 | + |
|
334 | + $entities = []; |
|
335 | + |
|
336 | + while($row = $stmt->fetch()){ |
|
337 | + $entities[] = $this->mapRowToEntity($row); |
|
338 | + } |
|
339 | + |
|
340 | + $stmt->closeCursor(); |
|
341 | + |
|
342 | + return $entities; |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * Returns an db result and throws exceptions when there are more or less |
|
348 | + * results |
|
349 | + * @param string $sql the sql query |
|
350 | + * @param array $params the parameters of the sql query |
|
351 | + * @param int $limit the maximum number of rows |
|
352 | + * @param int $offset from which row we want to start |
|
353 | + * @throws DoesNotExistException if the item does not exist |
|
354 | + * @throws MultipleObjectsReturnedException if more than one item exist |
|
355 | + * @return Entity the entity |
|
356 | + * @since 7.0.0 |
|
357 | + */ |
|
358 | + protected function findEntity($sql, array $params=[], $limit=null, $offset=null){ |
|
359 | + return $this->mapRowToEntity($this->findOneQuery($sql, $params, $limit, $offset)); |
|
360 | + } |
|
361 | 361 | |
362 | 362 | |
363 | 363 | } |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | * mapped to queries without using sql |
49 | 49 | * @since 7.0.0 |
50 | 50 | */ |
51 | - public function __construct(IDBConnection $db, $tableName, $entityClass=null){ |
|
51 | + public function __construct(IDBConnection $db, $tableName, $entityClass = null) { |
|
52 | 52 | $this->db = $db; |
53 | - $this->tableName = '*PREFIX*' . $tableName; |
|
53 | + $this->tableName = '*PREFIX*'.$tableName; |
|
54 | 54 | |
55 | 55 | // if not given set the entity name to the class without the mapper part |
56 | 56 | // cache it here for later use since reflection is slow |
57 | - if($entityClass === null) { |
|
57 | + if ($entityClass === null) { |
|
58 | 58 | $this->entityClass = str_replace('Mapper', '', get_class($this)); |
59 | 59 | } else { |
60 | 60 | $this->entityClass = $entityClass; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return string the table name |
67 | 67 | * @since 7.0.0 |
68 | 68 | */ |
69 | - public function getTableName(){ |
|
69 | + public function getTableName() { |
|
70 | 70 | return $this->tableName; |
71 | 71 | } |
72 | 72 | |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @return Entity the deleted entity |
78 | 78 | * @since 7.0.0 - return value added in 8.1.0 |
79 | 79 | */ |
80 | - public function delete(Entity $entity){ |
|
81 | - $sql = 'DELETE FROM `' . $this->tableName . '` WHERE `id` = ?'; |
|
80 | + public function delete(Entity $entity) { |
|
81 | + $sql = 'DELETE FROM `'.$this->tableName.'` WHERE `id` = ?'; |
|
82 | 82 | $stmt = $this->execute($sql, [$entity->getId()]); |
83 | 83 | $stmt->closeCursor(); |
84 | 84 | return $entity; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return Entity the saved entity with the set id |
92 | 92 | * @since 7.0.0 |
93 | 93 | */ |
94 | - public function insert(Entity $entity){ |
|
94 | + public function insert(Entity $entity) { |
|
95 | 95 | // get updated fields to save, fields have to be set using a setter to |
96 | 96 | // be saved |
97 | 97 | $properties = $entity->getUpdatedFields(); |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | |
102 | 102 | // build the fields |
103 | 103 | $i = 0; |
104 | - foreach($properties as $property => $updated) { |
|
104 | + foreach ($properties as $property => $updated) { |
|
105 | 105 | $column = $entity->propertyToColumn($property); |
106 | - $getter = 'get' . ucfirst($property); |
|
106 | + $getter = 'get'.ucfirst($property); |
|
107 | 107 | |
108 | - $columns .= '`' . $column . '`'; |
|
108 | + $columns .= '`'.$column.'`'; |
|
109 | 109 | $values .= '?'; |
110 | 110 | |
111 | 111 | // only append colon if there are more entries |
112 | - if($i < count($properties)-1){ |
|
112 | + if ($i < count($properties) - 1) { |
|
113 | 113 | $columns .= ','; |
114 | 114 | $values .= ','; |
115 | 115 | } |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | |
120 | 120 | } |
121 | 121 | |
122 | - $sql = 'INSERT INTO `' . $this->tableName . '`(' . |
|
123 | - $columns . ') VALUES(' . $values . ')'; |
|
122 | + $sql = 'INSERT INTO `'.$this->tableName.'`('. |
|
123 | + $columns.') VALUES('.$values.')'; |
|
124 | 124 | |
125 | 125 | $stmt = $this->execute($sql, $params); |
126 | 126 | |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | * @return Entity the saved entity with the set id |
141 | 141 | * @since 7.0.0 - return value was added in 8.0.0 |
142 | 142 | */ |
143 | - public function update(Entity $entity){ |
|
143 | + public function update(Entity $entity) { |
|
144 | 144 | // if entity wasn't changed it makes no sense to run a db query |
145 | 145 | $properties = $entity->getUpdatedFields(); |
146 | - if(count($properties) === 0) { |
|
146 | + if (count($properties) === 0) { |
|
147 | 147 | return $entity; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // entity needs an id |
151 | 151 | $id = $entity->getId(); |
152 | - if($id === null){ |
|
152 | + if ($id === null) { |
|
153 | 153 | throw new \InvalidArgumentException( |
154 | 154 | 'Entity which should be updated has no id'); |
155 | 155 | } |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | |
165 | 165 | // build the fields |
166 | 166 | $i = 0; |
167 | - foreach($properties as $property => $updated) { |
|
167 | + foreach ($properties as $property => $updated) { |
|
168 | 168 | |
169 | 169 | $column = $entity->propertyToColumn($property); |
170 | - $getter = 'get' . ucfirst($property); |
|
170 | + $getter = 'get'.ucfirst($property); |
|
171 | 171 | |
172 | - $columns .= '`' . $column . '` = ?'; |
|
172 | + $columns .= '`'.$column.'` = ?'; |
|
173 | 173 | |
174 | 174 | // only append colon if there are more entries |
175 | - if($i < count($properties)-1){ |
|
175 | + if ($i < count($properties) - 1) { |
|
176 | 176 | $columns .= ','; |
177 | 177 | } |
178 | 178 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | $i++; |
181 | 181 | } |
182 | 182 | |
183 | - $sql = 'UPDATE `' . $this->tableName . '` SET ' . |
|
184 | - $columns . ' WHERE `id` = ?'; |
|
183 | + $sql = 'UPDATE `'.$this->tableName.'` SET '. |
|
184 | + $columns.' WHERE `id` = ?'; |
|
185 | 185 | $params[] = $id; |
186 | 186 | |
187 | 187 | $stmt = $this->execute($sql, $params); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @return \PDOStatement the database query result |
228 | 228 | * @since 7.0.0 |
229 | 229 | */ |
230 | - protected function execute($sql, array $params=[], $limit=null, $offset=null){ |
|
230 | + protected function execute($sql, array $params = [], $limit = null, $offset = null) { |
|
231 | 231 | $query = $this->db->prepare($sql, $limit, $offset); |
232 | 232 | |
233 | 233 | if ($this->isAssocArray($params)) { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $query->bindValue($key, $param, $pdoConstant); |
237 | 237 | } |
238 | 238 | } else { |
239 | - $index = 1; // bindParam is 1 indexed |
|
239 | + $index = 1; // bindParam is 1 indexed |
|
240 | 240 | foreach ($params as $param) { |
241 | 241 | $pdoConstant = $this->getPDOType($param); |
242 | 242 | $query->bindValue($index, $param, $pdoConstant); |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | * @return array the result as row |
264 | 264 | * @since 7.0.0 |
265 | 265 | */ |
266 | - protected function findOneQuery($sql, array $params=[], $limit=null, $offset=null){ |
|
266 | + protected function findOneQuery($sql, array $params = [], $limit = null, $offset = null) { |
|
267 | 267 | $stmt = $this->execute($sql, $params, $limit, $offset); |
268 | 268 | $row = $stmt->fetch(); |
269 | 269 | |
270 | - if($row === false || $row === null){ |
|
270 | + if ($row === false || $row === null) { |
|
271 | 271 | $stmt->closeCursor(); |
272 | 272 | $msg = $this->buildDebugMessage( |
273 | 273 | 'Did expect one result but found none when executing', $sql, $params, $limit, $offset |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $row2 = $stmt->fetch(); |
278 | 278 | $stmt->closeCursor(); |
279 | 279 | //MDB2 returns null, PDO and doctrine false when no row is available |
280 | - if( ! ($row2 === false || $row2 === null )) { |
|
280 | + if (!($row2 === false || $row2 === null)) { |
|
281 | 281 | $msg = $this->buildDebugMessage( |
282 | 282 | 'Did not expect more than one result when executing', $sql, $params, $limit, $offset |
283 | 283 | ); |
@@ -298,12 +298,12 @@ discard block |
||
298 | 298 | * @return string formatted error message string |
299 | 299 | * @since 9.1.0 |
300 | 300 | */ |
301 | - private function buildDebugMessage($msg, $sql, array $params=[], $limit=null, $offset=null) { |
|
302 | - return $msg . |
|
303 | - ': query "' . $sql . '"; ' . |
|
304 | - 'parameters ' . print_r($params, true) . '; ' . |
|
305 | - 'limit "' . $limit . '"; '. |
|
306 | - 'offset "' . $offset . '"'; |
|
301 | + private function buildDebugMessage($msg, $sql, array $params = [], $limit = null, $offset = null) { |
|
302 | + return $msg. |
|
303 | + ': query "'.$sql.'"; '. |
|
304 | + 'parameters '.print_r($params, true).'; '. |
|
305 | + 'limit "'.$limit.'"; '. |
|
306 | + 'offset "'.$offset.'"'; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @since 7.0.0 |
316 | 316 | */ |
317 | 317 | protected function mapRowToEntity($row) { |
318 | - return call_user_func($this->entityClass .'::fromRow', $row); |
|
318 | + return call_user_func($this->entityClass.'::fromRow', $row); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | |
@@ -328,12 +328,12 @@ discard block |
||
328 | 328 | * @return array all fetched entities |
329 | 329 | * @since 7.0.0 |
330 | 330 | */ |
331 | - protected function findEntities($sql, array $params=[], $limit=null, $offset=null) { |
|
331 | + protected function findEntities($sql, array $params = [], $limit = null, $offset = null) { |
|
332 | 332 | $stmt = $this->execute($sql, $params, $limit, $offset); |
333 | 333 | |
334 | 334 | $entities = []; |
335 | 335 | |
336 | - while($row = $stmt->fetch()){ |
|
336 | + while ($row = $stmt->fetch()) { |
|
337 | 337 | $entities[] = $this->mapRowToEntity($row); |
338 | 338 | } |
339 | 339 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @return Entity the entity |
356 | 356 | * @since 7.0.0 |
357 | 357 | */ |
358 | - protected function findEntity($sql, array $params=[], $limit=null, $offset=null){ |
|
358 | + protected function findEntity($sql, array $params = [], $limit = null, $offset = null) { |
|
359 | 359 | return $this->mapRowToEntity($this->findOneQuery($sql, $params, $limit, $offset)); |
360 | 360 | } |
361 | 361 |
@@ -46,6 +46,7 @@ discard block |
||
46 | 46 | class Files { |
47 | 47 | /** |
48 | 48 | * Recusive deletion of folders |
49 | + * @param string $dir |
|
49 | 50 | * @return bool |
50 | 51 | * @since 5.0.0 |
51 | 52 | */ |
@@ -67,7 +68,7 @@ discard block |
||
67 | 68 | /** |
68 | 69 | * Search for files by mimetype |
69 | 70 | * @param string $mimetype |
70 | - * @return array |
|
71 | + * @return \OC\Files\FileInfo[] |
|
71 | 72 | * @since 6.0.0 |
72 | 73 | */ |
73 | 74 | static public function searchByMime( $mimetype ) { |
@@ -45,92 +45,92 @@ |
||
45 | 45 | * @since 5.0.0 |
46 | 46 | */ |
47 | 47 | class Files { |
48 | - /** |
|
49 | - * Recusive deletion of folders |
|
50 | - * @return bool |
|
51 | - * @since 5.0.0 |
|
52 | - */ |
|
53 | - static function rmdirr( $dir ) { |
|
54 | - return \OC_Helper::rmdirr( $dir ); |
|
55 | - } |
|
48 | + /** |
|
49 | + * Recusive deletion of folders |
|
50 | + * @return bool |
|
51 | + * @since 5.0.0 |
|
52 | + */ |
|
53 | + static function rmdirr( $dir ) { |
|
54 | + return \OC_Helper::rmdirr( $dir ); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Get the mimetype form a local file |
|
59 | - * @param string $path |
|
60 | - * @return string |
|
61 | - * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead |
|
62 | - * @since 5.0.0 |
|
63 | - */ |
|
64 | - static function getMimeType( $path ) { |
|
65 | - return \OC::$server->getMimeTypeDetector()->detect($path); |
|
66 | - } |
|
57 | + /** |
|
58 | + * Get the mimetype form a local file |
|
59 | + * @param string $path |
|
60 | + * @return string |
|
61 | + * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead |
|
62 | + * @since 5.0.0 |
|
63 | + */ |
|
64 | + static function getMimeType( $path ) { |
|
65 | + return \OC::$server->getMimeTypeDetector()->detect($path); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Search for files by mimetype |
|
70 | - * @param string $mimetype |
|
71 | - * @return array |
|
72 | - * @since 6.0.0 |
|
73 | - */ |
|
74 | - static public function searchByMime( $mimetype ) { |
|
75 | - return(\OC\Files\Filesystem::searchByMime( $mimetype )); |
|
76 | - } |
|
68 | + /** |
|
69 | + * Search for files by mimetype |
|
70 | + * @param string $mimetype |
|
71 | + * @return array |
|
72 | + * @since 6.0.0 |
|
73 | + */ |
|
74 | + static public function searchByMime( $mimetype ) { |
|
75 | + return(\OC\Files\Filesystem::searchByMime( $mimetype )); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Copy the contents of one stream to another |
|
80 | - * @param resource $source |
|
81 | - * @param resource $target |
|
82 | - * @return int the number of bytes copied |
|
83 | - * @since 5.0.0 |
|
84 | - */ |
|
85 | - public static function streamCopy( $source, $target ) { |
|
86 | - list($count, ) = \OC_Helper::streamCopy( $source, $target ); |
|
87 | - return $count; |
|
88 | - } |
|
78 | + /** |
|
79 | + * Copy the contents of one stream to another |
|
80 | + * @param resource $source |
|
81 | + * @param resource $target |
|
82 | + * @return int the number of bytes copied |
|
83 | + * @since 5.0.0 |
|
84 | + */ |
|
85 | + public static function streamCopy( $source, $target ) { |
|
86 | + list($count, ) = \OC_Helper::streamCopy( $source, $target ); |
|
87 | + return $count; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Create a temporary file with an unique filename |
|
92 | - * @param string $postfix |
|
93 | - * @return string |
|
94 | - * |
|
95 | - * temporary files are automatically cleaned up after the script is finished |
|
96 | - * @deprecated 8.1.0 use getTemporaryFile() of \OCP\ITempManager - \OC::$server->getTempManager() |
|
97 | - * @since 5.0.0 |
|
98 | - */ |
|
99 | - public static function tmpFile( $postfix='' ) { |
|
100 | - return \OC::$server->getTempManager()->getTemporaryFile($postfix); |
|
101 | - } |
|
90 | + /** |
|
91 | + * Create a temporary file with an unique filename |
|
92 | + * @param string $postfix |
|
93 | + * @return string |
|
94 | + * |
|
95 | + * temporary files are automatically cleaned up after the script is finished |
|
96 | + * @deprecated 8.1.0 use getTemporaryFile() of \OCP\ITempManager - \OC::$server->getTempManager() |
|
97 | + * @since 5.0.0 |
|
98 | + */ |
|
99 | + public static function tmpFile( $postfix='' ) { |
|
100 | + return \OC::$server->getTempManager()->getTemporaryFile($postfix); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Create a temporary folder with an unique filename |
|
105 | - * @return string |
|
106 | - * |
|
107 | - * temporary files are automatically cleaned up after the script is finished |
|
108 | - * @deprecated 8.1.0 use getTemporaryFolder() of \OCP\ITempManager - \OC::$server->getTempManager() |
|
109 | - * @since 5.0.0 |
|
110 | - */ |
|
111 | - public static function tmpFolder() { |
|
112 | - return \OC::$server->getTempManager()->getTemporaryFolder(); |
|
113 | - } |
|
103 | + /** |
|
104 | + * Create a temporary folder with an unique filename |
|
105 | + * @return string |
|
106 | + * |
|
107 | + * temporary files are automatically cleaned up after the script is finished |
|
108 | + * @deprecated 8.1.0 use getTemporaryFolder() of \OCP\ITempManager - \OC::$server->getTempManager() |
|
109 | + * @since 5.0.0 |
|
110 | + */ |
|
111 | + public static function tmpFolder() { |
|
112 | + return \OC::$server->getTempManager()->getTemporaryFolder(); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Adds a suffix to the name in case the file exists |
|
117 | - * @param string $path |
|
118 | - * @param string $filename |
|
119 | - * @return string |
|
120 | - * @since 5.0.0 |
|
121 | - */ |
|
122 | - public static function buildNotExistingFileName( $path, $filename ) { |
|
123 | - return(\OC_Helper::buildNotExistingFileName( $path, $filename )); |
|
124 | - } |
|
115 | + /** |
|
116 | + * Adds a suffix to the name in case the file exists |
|
117 | + * @param string $path |
|
118 | + * @param string $filename |
|
119 | + * @return string |
|
120 | + * @since 5.0.0 |
|
121 | + */ |
|
122 | + public static function buildNotExistingFileName( $path, $filename ) { |
|
123 | + return(\OC_Helper::buildNotExistingFileName( $path, $filename )); |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * Gets the Storage for an app - creates the needed folder if they are not |
|
128 | - * existent |
|
129 | - * @param string $app |
|
130 | - * @return \OC\Files\View |
|
131 | - * @since 5.0.0 |
|
132 | - */ |
|
133 | - public static function getStorage( $app ) { |
|
134 | - return \OC_App::getStorage( $app ); |
|
135 | - } |
|
126 | + /** |
|
127 | + * Gets the Storage for an app - creates the needed folder if they are not |
|
128 | + * existent |
|
129 | + * @param string $app |
|
130 | + * @return \OC\Files\View |
|
131 | + * @since 5.0.0 |
|
132 | + */ |
|
133 | + public static function getStorage( $app ) { |
|
134 | + return \OC_App::getStorage( $app ); |
|
135 | + } |
|
136 | 136 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @return bool |
51 | 51 | * @since 5.0.0 |
52 | 52 | */ |
53 | - static function rmdirr( $dir ) { |
|
54 | - return \OC_Helper::rmdirr( $dir ); |
|
53 | + static function rmdirr($dir) { |
|
54 | + return \OC_Helper::rmdirr($dir); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead |
62 | 62 | * @since 5.0.0 |
63 | 63 | */ |
64 | - static function getMimeType( $path ) { |
|
64 | + static function getMimeType($path) { |
|
65 | 65 | return \OC::$server->getMimeTypeDetector()->detect($path); |
66 | 66 | } |
67 | 67 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @return array |
72 | 72 | * @since 6.0.0 |
73 | 73 | */ |
74 | - static public function searchByMime( $mimetype ) { |
|
75 | - return(\OC\Files\Filesystem::searchByMime( $mimetype )); |
|
74 | + static public function searchByMime($mimetype) { |
|
75 | + return(\OC\Files\Filesystem::searchByMime($mimetype)); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return int the number of bytes copied |
83 | 83 | * @since 5.0.0 |
84 | 84 | */ |
85 | - public static function streamCopy( $source, $target ) { |
|
86 | - list($count, ) = \OC_Helper::streamCopy( $source, $target ); |
|
85 | + public static function streamCopy($source, $target) { |
|
86 | + list($count,) = \OC_Helper::streamCopy($source, $target); |
|
87 | 87 | return $count; |
88 | 88 | } |
89 | 89 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @deprecated 8.1.0 use getTemporaryFile() of \OCP\ITempManager - \OC::$server->getTempManager() |
97 | 97 | * @since 5.0.0 |
98 | 98 | */ |
99 | - public static function tmpFile( $postfix='' ) { |
|
99 | + public static function tmpFile($postfix = '') { |
|
100 | 100 | return \OC::$server->getTempManager()->getTemporaryFile($postfix); |
101 | 101 | } |
102 | 102 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @return string |
120 | 120 | * @since 5.0.0 |
121 | 121 | */ |
122 | - public static function buildNotExistingFileName( $path, $filename ) { |
|
123 | - return(\OC_Helper::buildNotExistingFileName( $path, $filename )); |
|
122 | + public static function buildNotExistingFileName($path, $filename) { |
|
123 | + return(\OC_Helper::buildNotExistingFileName($path, $filename)); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @return \OC\Files\View |
131 | 131 | * @since 5.0.0 |
132 | 132 | */ |
133 | - public static function getStorage( $app ) { |
|
134 | - return \OC_App::getStorage( $app ); |
|
133 | + public static function getStorage($app) { |
|
134 | + return \OC_App::getStorage($app); |
|
135 | 135 | } |
136 | 136 | } |
@@ -30,7 +30,6 @@ |
||
30 | 30 | * StorageAuthException constructor. |
31 | 31 | * |
32 | 32 | * @param string $message |
33 | - * @param int $code |
|
34 | 33 | * @param \Exception $previous |
35 | 34 | * @since 9.0.0 |
36 | 35 | */ |
@@ -27,16 +27,16 @@ |
||
27 | 27 | */ |
28 | 28 | class StorageAuthException extends StorageNotAvailableException { |
29 | 29 | |
30 | - /** |
|
31 | - * StorageAuthException constructor. |
|
32 | - * |
|
33 | - * @param string $message |
|
34 | - * @param int $code |
|
35 | - * @param \Exception $previous |
|
36 | - * @since 9.0.0 |
|
37 | - */ |
|
38 | - public function __construct($message = '', \Exception $previous = null) { |
|
39 | - $l = \OC::$server->getL10N('core'); |
|
40 | - parent::__construct($l->t('Storage unauthorized. %s', $message), self::STATUS_UNAUTHORIZED, $previous); |
|
41 | - } |
|
30 | + /** |
|
31 | + * StorageAuthException constructor. |
|
32 | + * |
|
33 | + * @param string $message |
|
34 | + * @param int $code |
|
35 | + * @param \Exception $previous |
|
36 | + * @since 9.0.0 |
|
37 | + */ |
|
38 | + public function __construct($message = '', \Exception $previous = null) { |
|
39 | + $l = \OC::$server->getL10N('core'); |
|
40 | + parent::__construct($l->t('Storage unauthorized. %s', $message), self::STATUS_UNAUTHORIZED, $previous); |
|
41 | + } |
|
42 | 42 | } |
@@ -30,7 +30,6 @@ |
||
30 | 30 | * ExtStorageBadConfigException constructor. |
31 | 31 | * |
32 | 32 | * @param string $message |
33 | - * @param int $code |
|
34 | 33 | * @param \Exception $previous |
35 | 34 | * @since 9.0.0 |
36 | 35 | */ |
@@ -27,17 +27,17 @@ |
||
27 | 27 | */ |
28 | 28 | class StorageBadConfigException extends StorageNotAvailableException { |
29 | 29 | |
30 | - /** |
|
31 | - * ExtStorageBadConfigException constructor. |
|
32 | - * |
|
33 | - * @param string $message |
|
34 | - * @param int $code |
|
35 | - * @param \Exception $previous |
|
36 | - * @since 9.0.0 |
|
37 | - */ |
|
38 | - public function __construct($message = '', \Exception $previous = null) { |
|
39 | - $l = \OC::$server->getL10N('core'); |
|
40 | - parent::__construct($l->t('Storage incomplete configuration. %s', $message), self::STATUS_INCOMPLETE_CONF, $previous); |
|
41 | - } |
|
30 | + /** |
|
31 | + * ExtStorageBadConfigException constructor. |
|
32 | + * |
|
33 | + * @param string $message |
|
34 | + * @param int $code |
|
35 | + * @param \Exception $previous |
|
36 | + * @since 9.0.0 |
|
37 | + */ |
|
38 | + public function __construct($message = '', \Exception $previous = null) { |
|
39 | + $l = \OC::$server->getL10N('core'); |
|
40 | + parent::__construct($l->t('Storage incomplete configuration. %s', $message), self::STATUS_INCOMPLETE_CONF, $previous); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | } |
@@ -30,7 +30,6 @@ |
||
30 | 30 | * StorageConnectionException constructor. |
31 | 31 | * |
32 | 32 | * @param string $message |
33 | - * @param int $code |
|
34 | 33 | * @param \Exception $previous |
35 | 34 | * @since 9.0.0 |
36 | 35 | */ |
@@ -27,16 +27,16 @@ |
||
27 | 27 | */ |
28 | 28 | class StorageConnectionException extends StorageNotAvailableException { |
29 | 29 | |
30 | - /** |
|
31 | - * StorageConnectionException constructor. |
|
32 | - * |
|
33 | - * @param string $message |
|
34 | - * @param int $code |
|
35 | - * @param \Exception $previous |
|
36 | - * @since 9.0.0 |
|
37 | - */ |
|
38 | - public function __construct($message = '', \Exception $previous = null) { |
|
39 | - $l = \OC::$server->getL10N('core'); |
|
40 | - parent::__construct($l->t('Storage connection error. %s', $message), self::STATUS_NETWORK_ERROR, $previous); |
|
41 | - } |
|
30 | + /** |
|
31 | + * StorageConnectionException constructor. |
|
32 | + * |
|
33 | + * @param string $message |
|
34 | + * @param int $code |
|
35 | + * @param \Exception $previous |
|
36 | + * @since 9.0.0 |
|
37 | + */ |
|
38 | + public function __construct($message = '', \Exception $previous = null) { |
|
39 | + $l = \OC::$server->getL10N('core'); |
|
40 | + parent::__construct($l->t('Storage connection error. %s', $message), self::STATUS_NETWORK_ERROR, $previous); |
|
41 | + } |
|
42 | 42 | } |
@@ -30,7 +30,6 @@ |
||
30 | 30 | * StorageTimeoutException constructor. |
31 | 31 | * |
32 | 32 | * @param string $message |
33 | - * @param int $code |
|
34 | 33 | * @param \Exception $previous |
35 | 34 | * @since 9.0.0 |
36 | 35 | */ |
@@ -27,16 +27,16 @@ |
||
27 | 27 | */ |
28 | 28 | class StorageTimeoutException extends StorageNotAvailableException { |
29 | 29 | |
30 | - /** |
|
31 | - * StorageTimeoutException constructor. |
|
32 | - * |
|
33 | - * @param string $message |
|
34 | - * @param int $code |
|
35 | - * @param \Exception $previous |
|
36 | - * @since 9.0.0 |
|
37 | - */ |
|
38 | - public function __construct($message = '', \Exception $previous = null) { |
|
39 | - $l = \OC::$server->getL10N('core'); |
|
40 | - parent::__construct($l->t('Storage connection timeout. %s', $message), self::STATUS_TIMEOUT, $previous); |
|
41 | - } |
|
30 | + /** |
|
31 | + * StorageTimeoutException constructor. |
|
32 | + * |
|
33 | + * @param string $message |
|
34 | + * @param int $code |
|
35 | + * @param \Exception $previous |
|
36 | + * @since 9.0.0 |
|
37 | + */ |
|
38 | + public function __construct($message = '', \Exception $previous = null) { |
|
39 | + $l = \OC::$server->getL10N('core'); |
|
40 | + parent::__construct($l->t('Storage connection timeout. %s', $message), self::STATUS_TIMEOUT, $previous); |
|
41 | + } |
|
42 | 42 | } |
@@ -32,18 +32,21 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @param string $message |
34 | 34 | * @since 9.1.0 |
35 | + * @return void |
|
35 | 36 | */ |
36 | 37 | public function info($message); |
37 | 38 | |
38 | 39 | /** |
39 | 40 | * @param string $message |
40 | 41 | * @since 9.1.0 |
42 | + * @return void |
|
41 | 43 | */ |
42 | 44 | public function warning($message); |
43 | 45 | |
44 | 46 | /** |
45 | 47 | * @param int $max |
46 | 48 | * @since 9.1.0 |
49 | + * @return void |
|
47 | 50 | */ |
48 | 51 | public function startProgress($max = 0); |
49 | 52 | |
@@ -51,12 +54,13 @@ discard block |
||
51 | 54 | * @param int $step |
52 | 55 | * @param string $description |
53 | 56 | * @since 9.1.0 |
57 | + * @return void |
|
54 | 58 | */ |
55 | 59 | public function advance($step = 1, $description = ''); |
56 | 60 | |
57 | 61 | /** |
58 | - * @param int $max |
|
59 | 62 | * @since 9.1.0 |
63 | + * @return void |
|
60 | 64 | */ |
61 | 65 | public function finishProgress(); |
62 | 66 |
@@ -30,35 +30,35 @@ |
||
30 | 30 | */ |
31 | 31 | interface IOutput { |
32 | 32 | |
33 | - /** |
|
34 | - * @param string $message |
|
35 | - * @since 9.1.0 |
|
36 | - */ |
|
37 | - public function info($message); |
|
33 | + /** |
|
34 | + * @param string $message |
|
35 | + * @since 9.1.0 |
|
36 | + */ |
|
37 | + public function info($message); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $message |
|
41 | - * @since 9.1.0 |
|
42 | - */ |
|
43 | - public function warning($message); |
|
39 | + /** |
|
40 | + * @param string $message |
|
41 | + * @since 9.1.0 |
|
42 | + */ |
|
43 | + public function warning($message); |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param int $max |
|
47 | - * @since 9.1.0 |
|
48 | - */ |
|
49 | - public function startProgress($max = 0); |
|
45 | + /** |
|
46 | + * @param int $max |
|
47 | + * @since 9.1.0 |
|
48 | + */ |
|
49 | + public function startProgress($max = 0); |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param int $step |
|
53 | - * @param string $description |
|
54 | - * @since 9.1.0 |
|
55 | - */ |
|
56 | - public function advance($step = 1, $description = ''); |
|
51 | + /** |
|
52 | + * @param int $step |
|
53 | + * @param string $description |
|
54 | + * @since 9.1.0 |
|
55 | + */ |
|
56 | + public function advance($step = 1, $description = ''); |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param int $max |
|
60 | - * @since 9.1.0 |
|
61 | - */ |
|
62 | - public function finishProgress(); |
|
58 | + /** |
|
59 | + * @param int $max |
|
60 | + * @since 9.1.0 |
|
61 | + */ |
|
62 | + public function finishProgress(); |
|
63 | 63 | |
64 | 64 | } |
@@ -102,17 +102,19 @@ discard block |
||
102 | 102 | * with the same attributes |
103 | 103 | * |
104 | 104 | * @since 9.0.0 |
105 | + * @return void |
|
105 | 106 | */ |
106 | 107 | public function updateTag($tagId, $newName, $userVisible, $userAssignable); |
107 | 108 | |
108 | 109 | /** |
109 | 110 | * Delete the given tags from the database and all their relationships. |
110 | 111 | * |
111 | - * @param string|array $tagIds array of tag ids |
|
112 | + * @param string $tagIds array of tag ids |
|
112 | 113 | * |
113 | 114 | * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist |
114 | 115 | * |
115 | 116 | * @since 9.0.0 |
117 | + * @return void |
|
116 | 118 | */ |
117 | 119 | public function deleteTags($tagIds); |
118 | 120 | |
@@ -123,7 +125,7 @@ discard block |
||
123 | 125 | * @param ISystemTag $tag tag to check permission for |
124 | 126 | * @param IUser $user user to check permission for |
125 | 127 | * |
126 | - * @return true if the user is allowed to assign/unassign the tag, false otherwise |
|
128 | + * @return boolean if the user is allowed to assign/unassign the tag, false otherwise |
|
127 | 129 | * |
128 | 130 | * @since 9.1.0 |
129 | 131 | */ |
@@ -133,9 +135,9 @@ discard block |
||
133 | 135 | * Checks whether the given user is allowed to see the tag with the given id. |
134 | 136 | * |
135 | 137 | * @param ISystemTag $tag tag to check permission for |
136 | - * @param IUser $user user to check permission for |
|
138 | + * @param IUser $userId user to check permission for |
|
137 | 139 | * |
138 | - * @return true if the user can see the tag, false otherwise |
|
140 | + * @return boolean if the user can see the tag, false otherwise |
|
139 | 141 | * |
140 | 142 | * @since 9.1.0 |
141 | 143 | */ |
@@ -148,6 +150,7 @@ discard block |
||
148 | 150 | * @param string[] $groupIds group ids of groups that can assign/unassign the tag |
149 | 151 | * |
150 | 152 | * @since 9.1.0 |
153 | + * @return void |
|
151 | 154 | */ |
152 | 155 | public function setTagGroups(ISystemTag $tag, $groupIds); |
153 | 156 |
@@ -33,133 +33,133 @@ |
||
33 | 33 | */ |
34 | 34 | interface ISystemTagManager { |
35 | 35 | |
36 | - /** |
|
37 | - * Returns the tag objects matching the given tag ids. |
|
38 | - * |
|
39 | - * @param array|string $tagIds id or array of unique ids of the tag to retrieve |
|
40 | - * |
|
41 | - * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key |
|
42 | - * |
|
43 | - * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.) |
|
44 | - * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist |
|
45 | - * The message contains a json_encoded array of the ids that could not be found |
|
46 | - * |
|
47 | - * @since 9.0.0 |
|
48 | - */ |
|
49 | - public function getTagsByIds($tagIds); |
|
36 | + /** |
|
37 | + * Returns the tag objects matching the given tag ids. |
|
38 | + * |
|
39 | + * @param array|string $tagIds id or array of unique ids of the tag to retrieve |
|
40 | + * |
|
41 | + * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key |
|
42 | + * |
|
43 | + * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.) |
|
44 | + * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist |
|
45 | + * The message contains a json_encoded array of the ids that could not be found |
|
46 | + * |
|
47 | + * @since 9.0.0 |
|
48 | + */ |
|
49 | + public function getTagsByIds($tagIds); |
|
50 | 50 | |
51 | - /** |
|
52 | - * Returns the tag object matching the given attributes. |
|
53 | - * |
|
54 | - * @param string $tagName tag name |
|
55 | - * @param bool $userVisible whether the tag is visible by users |
|
56 | - * @param bool $userAssignable whether the tag is assignable by users |
|
57 | - * |
|
58 | - * @return \OCP\SystemTag\ISystemTag system tag |
|
59 | - * |
|
60 | - * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist |
|
61 | - * |
|
62 | - * @since 9.0.0 |
|
63 | - */ |
|
64 | - public function getTag($tagName, $userVisible, $userAssignable); |
|
51 | + /** |
|
52 | + * Returns the tag object matching the given attributes. |
|
53 | + * |
|
54 | + * @param string $tagName tag name |
|
55 | + * @param bool $userVisible whether the tag is visible by users |
|
56 | + * @param bool $userAssignable whether the tag is assignable by users |
|
57 | + * |
|
58 | + * @return \OCP\SystemTag\ISystemTag system tag |
|
59 | + * |
|
60 | + * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist |
|
61 | + * |
|
62 | + * @since 9.0.0 |
|
63 | + */ |
|
64 | + public function getTag($tagName, $userVisible, $userAssignable); |
|
65 | 65 | |
66 | - /** |
|
67 | - * Creates the tag object using the given attributes. |
|
68 | - * |
|
69 | - * @param string $tagName tag name |
|
70 | - * @param bool $userVisible whether the tag is visible by users |
|
71 | - * @param bool $userAssignable whether the tag is assignable by users |
|
72 | - * |
|
73 | - * @return \OCP\SystemTag\ISystemTag system tag |
|
74 | - * |
|
75 | - * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists |
|
76 | - * |
|
77 | - * @since 9.0.0 |
|
78 | - */ |
|
79 | - public function createTag($tagName, $userVisible, $userAssignable); |
|
66 | + /** |
|
67 | + * Creates the tag object using the given attributes. |
|
68 | + * |
|
69 | + * @param string $tagName tag name |
|
70 | + * @param bool $userVisible whether the tag is visible by users |
|
71 | + * @param bool $userAssignable whether the tag is assignable by users |
|
72 | + * |
|
73 | + * @return \OCP\SystemTag\ISystemTag system tag |
|
74 | + * |
|
75 | + * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists |
|
76 | + * |
|
77 | + * @since 9.0.0 |
|
78 | + */ |
|
79 | + public function createTag($tagName, $userVisible, $userAssignable); |
|
80 | 80 | |
81 | - /** |
|
82 | - * Returns all known tags, optionally filtered by visibility. |
|
83 | - * |
|
84 | - * @param bool|null $visibilityFilter filter by visibility if non-null |
|
85 | - * @param string $nameSearchPattern optional search pattern for the tag name |
|
86 | - * |
|
87 | - * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found |
|
88 | - * |
|
89 | - * @since 9.0.0 |
|
90 | - */ |
|
91 | - public function getAllTags($visibilityFilter = null, $nameSearchPattern = null); |
|
81 | + /** |
|
82 | + * Returns all known tags, optionally filtered by visibility. |
|
83 | + * |
|
84 | + * @param bool|null $visibilityFilter filter by visibility if non-null |
|
85 | + * @param string $nameSearchPattern optional search pattern for the tag name |
|
86 | + * |
|
87 | + * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found |
|
88 | + * |
|
89 | + * @since 9.0.0 |
|
90 | + */ |
|
91 | + public function getAllTags($visibilityFilter = null, $nameSearchPattern = null); |
|
92 | 92 | |
93 | - /** |
|
94 | - * Updates the given tag |
|
95 | - * |
|
96 | - * @param string $tagId tag id |
|
97 | - * @param string $newName the new tag name |
|
98 | - * @param bool $userVisible whether the tag is visible by users |
|
99 | - * @param bool $userAssignable whether the tag is assignable by users |
|
100 | - * |
|
101 | - * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist |
|
102 | - * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag |
|
103 | - * with the same attributes |
|
104 | - * |
|
105 | - * @since 9.0.0 |
|
106 | - */ |
|
107 | - public function updateTag($tagId, $newName, $userVisible, $userAssignable); |
|
93 | + /** |
|
94 | + * Updates the given tag |
|
95 | + * |
|
96 | + * @param string $tagId tag id |
|
97 | + * @param string $newName the new tag name |
|
98 | + * @param bool $userVisible whether the tag is visible by users |
|
99 | + * @param bool $userAssignable whether the tag is assignable by users |
|
100 | + * |
|
101 | + * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist |
|
102 | + * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag |
|
103 | + * with the same attributes |
|
104 | + * |
|
105 | + * @since 9.0.0 |
|
106 | + */ |
|
107 | + public function updateTag($tagId, $newName, $userVisible, $userAssignable); |
|
108 | 108 | |
109 | - /** |
|
110 | - * Delete the given tags from the database and all their relationships. |
|
111 | - * |
|
112 | - * @param string|array $tagIds array of tag ids |
|
113 | - * |
|
114 | - * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist |
|
115 | - * |
|
116 | - * @since 9.0.0 |
|
117 | - */ |
|
118 | - public function deleteTags($tagIds); |
|
109 | + /** |
|
110 | + * Delete the given tags from the database and all their relationships. |
|
111 | + * |
|
112 | + * @param string|array $tagIds array of tag ids |
|
113 | + * |
|
114 | + * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist |
|
115 | + * |
|
116 | + * @since 9.0.0 |
|
117 | + */ |
|
118 | + public function deleteTags($tagIds); |
|
119 | 119 | |
120 | - /** |
|
121 | - * Checks whether the given user is allowed to assign/unassign the tag with the |
|
122 | - * given id. |
|
123 | - * |
|
124 | - * @param ISystemTag $tag tag to check permission for |
|
125 | - * @param IUser $user user to check permission for |
|
126 | - * |
|
127 | - * @return true if the user is allowed to assign/unassign the tag, false otherwise |
|
128 | - * |
|
129 | - * @since 9.1.0 |
|
130 | - */ |
|
131 | - public function canUserAssignTag(ISystemTag $tag, IUser $user); |
|
120 | + /** |
|
121 | + * Checks whether the given user is allowed to assign/unassign the tag with the |
|
122 | + * given id. |
|
123 | + * |
|
124 | + * @param ISystemTag $tag tag to check permission for |
|
125 | + * @param IUser $user user to check permission for |
|
126 | + * |
|
127 | + * @return true if the user is allowed to assign/unassign the tag, false otherwise |
|
128 | + * |
|
129 | + * @since 9.1.0 |
|
130 | + */ |
|
131 | + public function canUserAssignTag(ISystemTag $tag, IUser $user); |
|
132 | 132 | |
133 | - /** |
|
134 | - * Checks whether the given user is allowed to see the tag with the given id. |
|
135 | - * |
|
136 | - * @param ISystemTag $tag tag to check permission for |
|
137 | - * @param IUser $user user to check permission for |
|
138 | - * |
|
139 | - * @return true if the user can see the tag, false otherwise |
|
140 | - * |
|
141 | - * @since 9.1.0 |
|
142 | - */ |
|
143 | - public function canUserSeeTag(ISystemTag $tag, IUser $userId); |
|
133 | + /** |
|
134 | + * Checks whether the given user is allowed to see the tag with the given id. |
|
135 | + * |
|
136 | + * @param ISystemTag $tag tag to check permission for |
|
137 | + * @param IUser $user user to check permission for |
|
138 | + * |
|
139 | + * @return true if the user can see the tag, false otherwise |
|
140 | + * |
|
141 | + * @since 9.1.0 |
|
142 | + */ |
|
143 | + public function canUserSeeTag(ISystemTag $tag, IUser $userId); |
|
144 | 144 | |
145 | - /** |
|
146 | - * Set groups that can assign a given tag. |
|
147 | - * |
|
148 | - * @param ISystemTag $tag tag for group assignment |
|
149 | - * @param string[] $groupIds group ids of groups that can assign/unassign the tag |
|
150 | - * |
|
151 | - * @since 9.1.0 |
|
152 | - */ |
|
153 | - public function setTagGroups(ISystemTag $tag, $groupIds); |
|
145 | + /** |
|
146 | + * Set groups that can assign a given tag. |
|
147 | + * |
|
148 | + * @param ISystemTag $tag tag for group assignment |
|
149 | + * @param string[] $groupIds group ids of groups that can assign/unassign the tag |
|
150 | + * |
|
151 | + * @since 9.1.0 |
|
152 | + */ |
|
153 | + public function setTagGroups(ISystemTag $tag, $groupIds); |
|
154 | 154 | |
155 | - /** |
|
156 | - * Get groups that can assign a given tag. |
|
157 | - * |
|
158 | - * @param ISystemTag $tag tag for group assignment |
|
159 | - * |
|
160 | - * @return string[] group ids of groups that can assign/unassign the tag |
|
161 | - * |
|
162 | - * @since 9.1.0 |
|
163 | - */ |
|
164 | - public function getTagGroups(ISystemTag $tag); |
|
155 | + /** |
|
156 | + * Get groups that can assign a given tag. |
|
157 | + * |
|
158 | + * @param ISystemTag $tag tag for group assignment |
|
159 | + * |
|
160 | + * @return string[] group ids of groups that can assign/unassign the tag |
|
161 | + * |
|
162 | + * @since 9.1.0 |
|
163 | + */ |
|
164 | + public function getTagGroups(ISystemTag $tag); |
|
165 | 165 | } |