1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the Location Gateway class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query; |
12
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query\Criterion; |
13
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway; |
14
|
|
|
use eZ\Publish\SPI\Persistence\Content\Location\UpdateStruct; |
15
|
|
|
use eZ\Publish\SPI\Persistence\Content\Location\CreateStruct; |
16
|
|
|
use Doctrine\DBAL\DBALException; |
17
|
|
|
use PDOException; |
18
|
|
|
use RuntimeException; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Base class for location gateways. |
22
|
|
|
*/ |
23
|
|
|
class ExceptionConversion extends Gateway |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* The wrapped gateway. |
27
|
|
|
* |
28
|
|
|
* @var Gateway |
29
|
|
|
*/ |
30
|
|
|
protected $innerGateway; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Creates a new exception conversion gateway around $innerGateway. |
34
|
|
|
* |
35
|
|
|
* @param Gateway $innerGateway |
36
|
|
|
*/ |
37
|
|
|
public function __construct(Gateway $innerGateway) |
38
|
|
|
{ |
39
|
|
|
$this->innerGateway = $innerGateway; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
|
|
public function getBasicNodeData($nodeId, array $translations = null, bool $useAlwaysAvailable = true) |
46
|
|
|
{ |
47
|
|
|
try { |
48
|
|
|
return $this->innerGateway->getBasicNodeData($nodeId, $translations, $useAlwaysAvailable); |
|
|
|
|
49
|
|
|
} catch (DBALException $e) { |
50
|
|
|
throw new RuntimeException('Database error', 0, $e); |
51
|
|
|
} catch (PDOException $e) { |
52
|
|
|
throw new RuntimeException('Database error', 0, $e); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
*/ |
59
|
|
|
public function getNodeDataList(array $locationIds, array $translations = null, bool $useAlwaysAvailable = true): iterable |
60
|
|
|
{ |
61
|
|
|
try { |
62
|
|
|
return $this->innerGateway->getNodeDataList($locationIds, $translations, $useAlwaysAvailable); |
|
|
|
|
63
|
|
|
} catch (DBALException | PDOException $e) { |
64
|
|
|
throw new RuntimeException('Database error', 0, $e); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
|
|
public function getBasicNodeDataByRemoteId($remoteId, array $translations = null, bool $useAlwaysAvailable = true) |
72
|
|
|
{ |
73
|
|
|
try { |
74
|
|
|
return $this->innerGateway->getBasicNodeDataByRemoteId($remoteId, $translations, $useAlwaysAvailable); |
|
|
|
|
75
|
|
|
} catch (DBALException $e) { |
76
|
|
|
throw new RuntimeException('Database error', 0, $e); |
77
|
|
|
} catch (PDOException $e) { |
78
|
|
|
throw new RuntimeException('Database error', 0, $e); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Returns total count and data for all Locations satisfying the parameters. |
84
|
|
|
* |
85
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion |
86
|
|
|
* @param int $offset |
87
|
|
|
* @param int|null $limit |
88
|
|
|
* @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause[] $sortClauses |
89
|
|
|
* |
90
|
|
|
* @return mixed[][] |
91
|
|
|
*/ |
92
|
|
|
public function find(Criterion $criterion, $offset = 0, $limit = null, array $sortClauses = null) |
93
|
|
|
{ |
94
|
|
|
try { |
95
|
|
|
return $this->innerGateway->find($criterion, $offset, $limit, $sortClauses); |
|
|
|
|
96
|
|
|
} catch (DBALException $e) { |
97
|
|
|
throw new RuntimeException('Database error', 0, $e); |
98
|
|
|
} catch (PDOException $e) { |
99
|
|
|
throw new RuntimeException('Database error', 0, $e); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Loads data for all Locations for $contentId, optionally only in the |
105
|
|
|
* subtree starting at $rootLocationId. |
106
|
|
|
* |
107
|
|
|
* @param int $contentId |
108
|
|
|
* @param int $rootLocationId |
109
|
|
|
* |
110
|
|
|
* @return array |
111
|
|
|
*/ |
112
|
|
|
public function loadLocationDataByContent($contentId, $rootLocationId = null) |
113
|
|
|
{ |
114
|
|
|
try { |
115
|
|
|
return $this->innerGateway->loadLocationDataByContent($contentId, $rootLocationId); |
116
|
|
|
} catch (DBALException $e) { |
117
|
|
|
throw new RuntimeException('Database error', 0, $e); |
118
|
|
|
} catch (PDOException $e) { |
119
|
|
|
throw new RuntimeException('Database error', 0, $e); |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @see \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway::loadParentLocationsDataForDraftContent |
125
|
|
|
*/ |
126
|
|
|
public function loadParentLocationsDataForDraftContent($contentId) |
127
|
|
|
{ |
128
|
|
|
try { |
129
|
|
|
return $this->innerGateway->loadParentLocationsDataForDraftContent($contentId); |
130
|
|
|
} catch (DBALException $e) { |
131
|
|
|
throw new RuntimeException('Database error', 0, $e); |
132
|
|
|
} catch (PDOException $e) { |
133
|
|
|
throw new RuntimeException('Database error', 0, $e); |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Find all content in the given subtree. |
139
|
|
|
* |
140
|
|
|
* @param mixed $sourceId |
141
|
|
|
* @param bool $onlyIds |
142
|
|
|
* |
143
|
|
|
* @return array |
144
|
|
|
*/ |
145
|
|
|
public function getSubtreeContent($sourceId, $onlyIds = false) |
146
|
|
|
{ |
147
|
|
|
try { |
148
|
|
|
return $this->innerGateway->getSubtreeContent($sourceId, $onlyIds); |
149
|
|
|
} catch (DBALException $e) { |
150
|
|
|
throw new RuntimeException('Database error', 0, $e); |
151
|
|
|
} catch (PDOException $e) { |
152
|
|
|
throw new RuntimeException('Database error', 0, $e); |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Returns data for the first level children of the location identified by given $locationId. |
158
|
|
|
* |
159
|
|
|
* @param mixed $locationId |
160
|
|
|
* |
161
|
|
|
* @return array |
162
|
|
|
*/ |
163
|
|
|
public function getChildren($locationId) |
164
|
|
|
{ |
165
|
|
|
try { |
166
|
|
|
return $this->innerGateway->getChildren($locationId); |
167
|
|
|
} catch (DBALException $e) { |
168
|
|
|
throw new RuntimeException('Database error', 0, $e); |
169
|
|
|
} catch (PDOException $e) { |
170
|
|
|
throw new RuntimeException('Database error', 0, $e); |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Update path strings to move nodes in the ezcontentobject_tree table. |
176
|
|
|
* |
177
|
|
|
* This query can likely be optimized to use some more advanced string |
178
|
|
|
* operations, which then depend on the respective database. |
179
|
|
|
* |
180
|
|
|
* @todo optimize |
181
|
|
|
* |
182
|
|
|
* @param array $fromPathString |
183
|
|
|
* @param array $toPathString |
184
|
|
|
*/ |
185
|
|
|
public function moveSubtreeNodes(array $fromPathString, array $toPathString) |
186
|
|
|
{ |
187
|
|
|
try { |
188
|
|
|
return $this->innerGateway->moveSubtreeNodes($fromPathString, $toPathString); |
189
|
|
|
} catch (DBALException $e) { |
190
|
|
|
throw new RuntimeException('Database error', 0, $e); |
191
|
|
|
} catch (PDOException $e) { |
192
|
|
|
throw new RuntimeException('Database error', 0, $e); |
193
|
|
|
} |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Updated subtree modification time for all nodes on path. |
198
|
|
|
* |
199
|
|
|
* @param string $pathString |
200
|
|
|
* @param int|null $timestamp |
201
|
|
|
*/ |
202
|
|
|
public function updateSubtreeModificationTime($pathString, $timestamp = null) |
203
|
|
|
{ |
204
|
|
|
try { |
205
|
|
|
return $this->innerGateway->updateSubtreeModificationTime($pathString, $timestamp); |
206
|
|
|
} catch (DBALException $e) { |
207
|
|
|
throw new RuntimeException('Database error', 0, $e); |
208
|
|
|
} catch (PDOException $e) { |
209
|
|
|
throw new RuntimeException('Database error', 0, $e); |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Update node assignment table. |
215
|
|
|
* |
216
|
|
|
* @param int $contentObjectId |
217
|
|
|
* @param int $oldParent |
218
|
|
|
* @param int $newParent |
219
|
|
|
* @param int $opcode |
220
|
|
|
*/ |
221
|
|
|
public function updateNodeAssignment($contentObjectId, $oldParent, $newParent, $opcode) |
222
|
|
|
{ |
223
|
|
|
try { |
224
|
|
|
return $this->innerGateway->updateNodeAssignment($contentObjectId, $oldParent, $newParent, $opcode); |
225
|
|
|
} catch (DBALException $e) { |
226
|
|
|
throw new RuntimeException('Database error', 0, $e); |
227
|
|
|
} catch (PDOException $e) { |
228
|
|
|
throw new RuntimeException('Database error', 0, $e); |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Create locations from node assignments. |
234
|
|
|
* |
235
|
|
|
* Convert existing node assignments into real locations. |
236
|
|
|
* |
237
|
|
|
* @param mixed $contentId |
238
|
|
|
* @param mixed $versionNo |
239
|
|
|
*/ |
240
|
|
|
public function createLocationsFromNodeAssignments($contentId, $versionNo) |
241
|
|
|
{ |
242
|
|
|
try { |
243
|
|
|
return $this->innerGateway->createLocationsFromNodeAssignments($contentId, $versionNo); |
244
|
|
|
} catch (DBALException $e) { |
245
|
|
|
throw new RuntimeException('Database error', 0, $e); |
246
|
|
|
} catch (PDOException $e) { |
247
|
|
|
throw new RuntimeException('Database error', 0, $e); |
248
|
|
|
} |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Updates all Locations of content identified with $contentId with $versionNo. |
253
|
|
|
* |
254
|
|
|
* @param mixed $contentId |
255
|
|
|
* @param mixed $versionNo |
256
|
|
|
*/ |
257
|
|
|
public function updateLocationsContentVersionNo($contentId, $versionNo) |
258
|
|
|
{ |
259
|
|
|
try { |
260
|
|
|
return $this->innerGateway->updateLocationsContentVersionNo($contentId, $versionNo); |
261
|
|
|
} catch (DBALException $e) { |
262
|
|
|
throw new RuntimeException('Database error', 0, $e); |
263
|
|
|
} catch (PDOException $e) { |
264
|
|
|
throw new RuntimeException('Database error', 0, $e); |
265
|
|
|
} |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* Sets a location to be hidden, and it self + all children to invisible. |
270
|
|
|
* |
271
|
|
|
* @param string $pathString |
272
|
|
|
*/ |
273
|
|
|
public function hideSubtree($pathString) |
274
|
|
|
{ |
275
|
|
|
try { |
276
|
|
|
return $this->innerGateway->hideSubtree($pathString); |
277
|
|
|
} catch (DBALException $e) { |
278
|
|
|
throw new RuntimeException('Database error', 0, $e); |
279
|
|
|
} catch (PDOException $e) { |
280
|
|
|
throw new RuntimeException('Database error', 0, $e); |
281
|
|
|
} |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Sets a location to be unhidden, and self + children to visible unless a parent is hiding the tree. |
286
|
|
|
* If not make sure only children down to first hidden node is marked visible. |
287
|
|
|
* |
288
|
|
|
* @param string $pathString |
289
|
|
|
*/ |
290
|
|
|
public function unHideSubtree($pathString) |
291
|
|
|
{ |
292
|
|
|
try { |
293
|
|
|
return $this->innerGateway->unHideSubtree($pathString); |
294
|
|
|
} catch (DBALException $e) { |
295
|
|
|
throw new RuntimeException('Database error', 0, $e); |
296
|
|
|
} catch (PDOException $e) { |
297
|
|
|
throw new RuntimeException('Database error', 0, $e); |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* Swaps the content object being pointed to by a location object. |
303
|
|
|
* |
304
|
|
|
* Make the location identified by $locationId1 refer to the Content |
305
|
|
|
* referred to by $locationId2 and vice versa. |
306
|
|
|
* |
307
|
|
|
* @param mixed $locationId1 |
308
|
|
|
* @param mixed $locationId2 |
309
|
|
|
* |
310
|
|
|
* @return bool |
311
|
|
|
*/ |
312
|
|
|
public function swap($locationId1, $locationId2) |
313
|
|
|
{ |
314
|
|
|
try { |
315
|
|
|
return $this->innerGateway->swap($locationId1, $locationId2); |
316
|
|
|
} catch (DBALException $e) { |
317
|
|
|
throw new RuntimeException('Database error', 0, $e); |
318
|
|
|
} catch (PDOException $e) { |
319
|
|
|
throw new RuntimeException('Database error', 0, $e); |
320
|
|
|
} |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* Creates a new location in given $parentNode. |
325
|
|
|
* |
326
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct $createStruct |
327
|
|
|
* @param array $parentNode |
328
|
|
|
* |
329
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\Location |
330
|
|
|
*/ |
331
|
|
|
public function create(CreateStruct $createStruct, array $parentNode) |
332
|
|
|
{ |
333
|
|
|
try { |
334
|
|
|
return $this->innerGateway->create($createStruct, $parentNode); |
335
|
|
|
} catch (DBALException $e) { |
336
|
|
|
throw new RuntimeException('Database error', 0, $e); |
337
|
|
|
} catch (PDOException $e) { |
338
|
|
|
throw new RuntimeException('Database error', 0, $e); |
339
|
|
|
} |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
/** |
343
|
|
|
* Create an entry in the node assignment table. |
344
|
|
|
* |
345
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct $createStruct |
346
|
|
|
* @param mixed $parentNodeId |
347
|
|
|
* @param int $type |
348
|
|
|
*/ |
349
|
|
|
public function createNodeAssignment(CreateStruct $createStruct, $parentNodeId, $type = self::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP) |
350
|
|
|
{ |
351
|
|
|
try { |
352
|
|
|
return $this->innerGateway->createNodeAssignment($createStruct, $parentNodeId, $type); |
353
|
|
|
} catch (DBALException $e) { |
354
|
|
|
throw new RuntimeException('Database error', 0, $e); |
355
|
|
|
} catch (PDOException $e) { |
356
|
|
|
throw new RuntimeException('Database error', 0, $e); |
357
|
|
|
} |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* Deletes node assignment for given $contentId and $versionNo. |
362
|
|
|
* |
363
|
|
|
* @param int $contentId |
364
|
|
|
* @param int $versionNo |
365
|
|
|
*/ |
366
|
|
|
public function deleteNodeAssignment($contentId, $versionNo = null) |
367
|
|
|
{ |
368
|
|
|
try { |
369
|
|
|
return $this->innerGateway->deleteNodeAssignment($contentId, $versionNo); |
370
|
|
|
} catch (DBALException $e) { |
371
|
|
|
throw new RuntimeException('Database error', 0, $e); |
372
|
|
|
} catch (PDOException $e) { |
373
|
|
|
throw new RuntimeException('Database error', 0, $e); |
374
|
|
|
} |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* Updates an existing location. |
379
|
|
|
* |
380
|
|
|
* Will not throw anything if location id is invalid or no entries are affected. |
381
|
|
|
* |
382
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\Location\UpdateStruct $location |
383
|
|
|
* @param int $locationId |
384
|
|
|
*/ |
385
|
|
|
public function update(UpdateStruct $location, $locationId) |
386
|
|
|
{ |
387
|
|
|
try { |
388
|
|
|
return $this->innerGateway->update($location, $locationId); |
389
|
|
|
} catch (DBALException $e) { |
390
|
|
|
throw new RuntimeException('Database error', 0, $e); |
391
|
|
|
} catch (PDOException $e) { |
392
|
|
|
throw new RuntimeException('Database error', 0, $e); |
393
|
|
|
} |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* Updates path identification string for given $locationId. |
398
|
|
|
* |
399
|
|
|
* @param mixed $locationId |
400
|
|
|
* @param mixed $parentLocationId |
401
|
|
|
* @param string $text |
402
|
|
|
*/ |
403
|
|
|
public function updatePathIdentificationString($locationId, $parentLocationId, $text) |
404
|
|
|
{ |
405
|
|
|
try { |
406
|
|
|
return $this->innerGateway->updatePathIdentificationString($locationId, $parentLocationId, $text); |
407
|
|
|
} catch (DBALException $e) { |
408
|
|
|
throw new RuntimeException('Database error', 0, $e); |
409
|
|
|
} catch (PDOException $e) { |
410
|
|
|
throw new RuntimeException('Database error', 0, $e); |
411
|
|
|
} |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* Deletes ezcontentobject_tree row for given $locationId (node_id). |
416
|
|
|
* |
417
|
|
|
* @param mixed $locationId |
418
|
|
|
*/ |
419
|
|
|
public function removeLocation($locationId) |
420
|
|
|
{ |
421
|
|
|
try { |
422
|
|
|
return $this->innerGateway->removeLocation($locationId); |
423
|
|
|
} catch (DBALException $e) { |
424
|
|
|
throw new RuntimeException('Database error', 0, $e); |
425
|
|
|
} catch (PDOException $e) { |
426
|
|
|
throw new RuntimeException('Database error', 0, $e); |
427
|
|
|
} |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* Returns id of the next in line node to be set as a new main node. |
432
|
|
|
* |
433
|
|
|
* This returns lowest node id for content identified by $contentId, and not of |
434
|
|
|
* the node identified by given $locationId (current main node). |
435
|
|
|
* Assumes that content has more than one location. |
436
|
|
|
* |
437
|
|
|
* @param mixed $contentId |
438
|
|
|
* @param mixed $locationId |
439
|
|
|
* |
440
|
|
|
* @return array |
441
|
|
|
*/ |
442
|
|
|
public function getFallbackMainNodeData($contentId, $locationId) |
443
|
|
|
{ |
444
|
|
|
try { |
445
|
|
|
return $this->innerGateway->getFallbackMainNodeData($contentId, $locationId); |
446
|
|
|
} catch (DBALException $e) { |
447
|
|
|
throw new RuntimeException('Database error', 0, $e); |
448
|
|
|
} catch (PDOException $e) { |
449
|
|
|
throw new RuntimeException('Database error', 0, $e); |
450
|
|
|
} |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* Sends a single location identified by given $locationId to the trash. |
455
|
|
|
* |
456
|
|
|
* The associated content object is left untouched. |
457
|
|
|
* |
458
|
|
|
* @param mixed $locationId |
459
|
|
|
* |
460
|
|
|
* @return bool |
461
|
|
|
*/ |
462
|
|
|
public function trashLocation($locationId) |
463
|
|
|
{ |
464
|
|
|
try { |
465
|
|
|
return $this->innerGateway->trashLocation($locationId); |
466
|
|
|
} catch (DBALException $e) { |
467
|
|
|
throw new RuntimeException('Database error', 0, $e); |
468
|
|
|
} catch (PDOException $e) { |
469
|
|
|
throw new RuntimeException('Database error', 0, $e); |
470
|
|
|
} |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* Returns a trashed location to normal state. |
475
|
|
|
* |
476
|
|
|
* Recreates the originally trashed location in the new position. If no new |
477
|
|
|
* position has been specified, it will be tried to re-create the location |
478
|
|
|
* at the old position. If this is not possible ( because the old location |
479
|
|
|
* does not exist any more) and exception is thrown. |
480
|
|
|
* |
481
|
|
|
* @param mixed $locationId |
482
|
|
|
* @param mixed $newParentId |
483
|
|
|
* |
484
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\Location |
485
|
|
|
*/ |
486
|
|
|
public function untrashLocation($locationId, $newParentId = null) |
487
|
|
|
{ |
488
|
|
|
try { |
489
|
|
|
return $this->innerGateway->untrashLocation($locationId, $newParentId); |
490
|
|
|
} catch (DBALException $e) { |
491
|
|
|
throw new RuntimeException('Database error', 0, $e); |
492
|
|
|
} catch (PDOException $e) { |
493
|
|
|
throw new RuntimeException('Database error', 0, $e); |
494
|
|
|
} |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
/** |
498
|
|
|
* Loads trash data specified by location ID. |
499
|
|
|
* |
500
|
|
|
* @param mixed $locationId |
501
|
|
|
* |
502
|
|
|
* @return array |
503
|
|
|
*/ |
504
|
|
|
public function loadTrashByLocation($locationId) |
505
|
|
|
{ |
506
|
|
|
try { |
507
|
|
|
return $this->innerGateway->loadTrashByLocation($locationId); |
508
|
|
|
} catch (DBALException $e) { |
509
|
|
|
throw new RuntimeException('Database error', 0, $e); |
510
|
|
|
} catch (PDOException $e) { |
511
|
|
|
throw new RuntimeException('Database error', 0, $e); |
512
|
|
|
} |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* Removes every entries in the trash. |
517
|
|
|
* Will NOT remove associated content objects nor attributes. |
518
|
|
|
* |
519
|
|
|
* Basically truncates ezcontentobject_trash table. |
520
|
|
|
*/ |
521
|
|
|
public function cleanupTrash() |
522
|
|
|
{ |
523
|
|
|
try { |
524
|
|
|
return $this->innerGateway->cleanupTrash(); |
525
|
|
|
} catch (DBALException $e) { |
526
|
|
|
throw new RuntimeException('Database error', 0, $e); |
527
|
|
|
} catch (PDOException $e) { |
528
|
|
|
throw new RuntimeException('Database error', 0, $e); |
529
|
|
|
} |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
/** |
533
|
|
|
* Lists trashed items. |
534
|
|
|
* Returns entries from ezcontentobject_trash. |
535
|
|
|
* |
536
|
|
|
* @param int $offset |
537
|
|
|
* @param int $limit |
538
|
|
|
* @param array $sort |
539
|
|
|
* |
540
|
|
|
* @return array |
541
|
|
|
*/ |
542
|
|
|
public function listTrashed($offset, $limit, array $sort = null) |
543
|
|
|
{ |
544
|
|
|
try { |
545
|
|
|
return $this->innerGateway->listTrashed($offset, $limit, $sort); |
546
|
|
|
} catch (DBALException $e) { |
547
|
|
|
throw new RuntimeException('Database error', 0, $e); |
548
|
|
|
} catch (PDOException $e) { |
549
|
|
|
throw new RuntimeException('Database error', 0, $e); |
550
|
|
|
} |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
/** |
554
|
|
|
* Removes trashed element identified by $id from trash. |
555
|
|
|
* Will NOT remove associated content object nor attributes. |
556
|
|
|
* |
557
|
|
|
* @param int $id The trashed location Id |
558
|
|
|
*/ |
559
|
|
|
public function removeElementFromTrash($id) |
560
|
|
|
{ |
561
|
|
|
try { |
562
|
|
|
return $this->innerGateway->removeElementFromTrash($id); |
563
|
|
|
} catch (DBALException $e) { |
564
|
|
|
throw new RuntimeException('Database error', 0, $e); |
565
|
|
|
} catch (PDOException $e) { |
566
|
|
|
throw new RuntimeException('Database error', 0, $e); |
567
|
|
|
} |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* Set section on all content objects in the subtree. |
572
|
|
|
* |
573
|
|
|
* @param mixed $pathString |
574
|
|
|
* @param mixed $sectionId |
575
|
|
|
* |
576
|
|
|
* @return bool |
577
|
|
|
*/ |
578
|
|
|
public function setSectionForSubtree($pathString, $sectionId) |
579
|
|
|
{ |
580
|
|
|
try { |
581
|
|
|
return $this->innerGateway->setSectionForSubtree($pathString, $sectionId); |
582
|
|
|
} catch (DBALException $e) { |
583
|
|
|
throw new RuntimeException('Database error', 0, $e); |
584
|
|
|
} catch (PDOException $e) { |
585
|
|
|
throw new RuntimeException('Database error', 0, $e); |
586
|
|
|
} |
587
|
|
|
} |
588
|
|
|
|
589
|
|
|
/** |
590
|
|
|
* Returns how many locations given content object identified by $contentId has. |
591
|
|
|
* |
592
|
|
|
* @param int $contentId |
593
|
|
|
* |
594
|
|
|
* @return int |
595
|
|
|
*/ |
596
|
|
|
public function countLocationsByContentId($contentId) |
597
|
|
|
{ |
598
|
|
|
try { |
599
|
|
|
return $this->innerGateway->countLocationsByContentId($contentId); |
600
|
|
|
} catch (DBALException $e) { |
601
|
|
|
throw new RuntimeException('Database error', 0, $e); |
602
|
|
|
} catch (PDOException $e) { |
603
|
|
|
throw new RuntimeException('Database error', 0, $e); |
604
|
|
|
} |
605
|
|
|
} |
606
|
|
|
|
607
|
|
|
/** |
608
|
|
|
* Changes main location of content identified by given $contentId to location identified by given $locationId. |
609
|
|
|
* |
610
|
|
|
* Updates ezcontentobject_tree table for the given $contentId and eznode_assignment table for the given |
611
|
|
|
* $contentId, $parentLocationId and $versionNo |
612
|
|
|
* |
613
|
|
|
* @param mixed $contentId |
614
|
|
|
* @param mixed $locationId |
615
|
|
|
* @param mixed $versionNo version number, needed to update eznode_assignment table |
616
|
|
|
* @param mixed $parentLocationId parent location of location identified by $locationId, needed to update |
617
|
|
|
* eznode_assignment table |
618
|
|
|
*/ |
619
|
|
|
public function changeMainLocation($contentId, $locationId, $versionNo, $parentLocationId) |
620
|
|
|
{ |
621
|
|
|
try { |
622
|
|
|
return $this->innerGateway->changeMainLocation($contentId, $locationId, $versionNo, $parentLocationId); |
623
|
|
|
} catch (DBALException $e) { |
624
|
|
|
throw new RuntimeException('Database error', 0, $e); |
625
|
|
|
} catch (PDOException $e) { |
626
|
|
|
throw new RuntimeException('Database error', 0, $e); |
627
|
|
|
} |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
/** |
631
|
|
|
* Get the total number of all Locations, except the Root node. |
632
|
|
|
* |
633
|
|
|
* @see loadAllLocationsData |
634
|
|
|
* |
635
|
|
|
* @return int |
636
|
|
|
*/ |
637
|
|
|
public function countAllLocations() |
638
|
|
|
{ |
639
|
|
|
try { |
640
|
|
|
return $this->innerGateway->countAllLocations(); |
641
|
|
|
} catch (DBALException $e) { |
642
|
|
|
throw new RuntimeException('Database error', 0, $e); |
643
|
|
|
} catch (PDOException $e) { |
644
|
|
|
throw new RuntimeException('Database error', 0, $e); |
645
|
|
|
} |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
/** |
649
|
|
|
* Load data of every Location, except the Root node. |
650
|
|
|
* |
651
|
|
|
* @param int $offset Paginator offset |
652
|
|
|
* @param int $limit Paginator limit |
653
|
|
|
* |
654
|
|
|
* @return array |
655
|
|
|
*/ |
656
|
|
|
public function loadAllLocationsData($offset, $limit) |
657
|
|
|
{ |
658
|
|
|
try { |
659
|
|
|
return $this->innerGateway->loadAllLocationsData($offset, $limit); |
660
|
|
|
} catch (DBALException $e) { |
661
|
|
|
throw new RuntimeException('Database error', 0, $e); |
662
|
|
|
} catch (PDOException $e) { |
663
|
|
|
throw new RuntimeException('Database error', 0, $e); |
664
|
|
|
} |
665
|
|
|
} |
666
|
|
|
} |
667
|
|
|
|
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.