1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the Content Gateway base 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
|
|
|
* @version //autogentag// |
10
|
|
|
*/ |
11
|
|
|
namespace eZ\Publish\Core\Persistence\Legacy\Content\Gateway; |
12
|
|
|
|
13
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Gateway; |
14
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue; |
15
|
|
|
use eZ\Publish\SPI\Persistence\Content; |
16
|
|
|
use eZ\Publish\SPI\Persistence\Content\CreateStruct; |
17
|
|
|
use eZ\Publish\SPI\Persistence\Content\UpdateStruct; |
18
|
|
|
use eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct; |
19
|
|
|
use eZ\Publish\SPI\Persistence\Content\VersionInfo; |
20
|
|
|
use eZ\Publish\SPI\Persistence\Content\Field; |
21
|
|
|
use eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct as RelationCreateStruct; |
22
|
|
|
use Doctrine\DBAL\DBALException; |
23
|
|
|
use PDOException; |
24
|
|
|
use RuntimeException; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Base class for content gateways. |
28
|
|
|
*/ |
29
|
|
|
class ExceptionConversion extends Gateway |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* The wrapped gateway. |
33
|
|
|
* |
34
|
|
|
* @var Gateway |
35
|
|
|
*/ |
36
|
|
|
protected $innerGateway; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Creates a new exception conversion gateway around $innerGateway. |
40
|
|
|
* |
41
|
|
|
* @param Gateway $innerGateway |
42
|
|
|
*/ |
43
|
|
|
public function __construct(Gateway $innerGateway) |
44
|
|
|
{ |
45
|
|
|
$this->innerGateway = $innerGateway; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Get context definition for external storage layers. |
50
|
|
|
* |
51
|
|
|
* @return array |
52
|
|
|
*/ |
53
|
|
|
public function getContext() |
54
|
|
|
{ |
55
|
|
|
try { |
56
|
|
|
return $this->innerGateway->getContext(); |
57
|
|
|
} catch (DBALException $e) { |
58
|
|
|
throw new RuntimeException('Database error', 0, $e); |
59
|
|
|
} catch (PDOException $e) { |
60
|
|
|
throw new RuntimeException('Database error', 0, $e); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Inserts a new content object. |
66
|
|
|
* |
67
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\CreateStruct $struct |
68
|
|
|
* @param mixed $currentVersionNo |
69
|
|
|
* |
70
|
|
|
* @return int ID |
71
|
|
|
*/ |
72
|
|
|
public function insertContentObject(CreateStruct $struct, $currentVersionNo = 1) |
73
|
|
|
{ |
74
|
|
|
try { |
75
|
|
|
return $this->innerGateway->insertContentObject($struct, $currentVersionNo); |
76
|
|
|
} catch (DBALException $e) { |
77
|
|
|
throw new RuntimeException('Database error', 0, $e); |
78
|
|
|
} catch (PDOException $e) { |
79
|
|
|
throw new RuntimeException('Database error', 0, $e); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Inserts a new version. |
85
|
|
|
* |
86
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo |
87
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\Field[] $fields |
88
|
|
|
* |
89
|
|
|
* @return int ID |
90
|
|
|
*/ |
91
|
|
|
public function insertVersion(VersionInfo $versionInfo, array $fields) |
92
|
|
|
{ |
93
|
|
|
try { |
94
|
|
|
return $this->innerGateway->insertVersion($versionInfo, $fields); |
95
|
|
|
} catch (DBALException $e) { |
96
|
|
|
throw new RuntimeException('Database error', 0, $e); |
97
|
|
|
} catch (PDOException $e) { |
98
|
|
|
throw new RuntimeException('Database error', 0, $e); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Updates an existing content identified by $contentId in respect to $struct. |
104
|
|
|
* |
105
|
|
|
* @param int $contentId |
106
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct $struct |
107
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $prePublishVersionInfo Provided on publish |
108
|
|
|
*/ |
109
|
|
|
public function updateContent($contentId, MetadataUpdateStruct $struct, VersionInfo $prePublishVersionInfo = null) |
110
|
|
|
{ |
111
|
|
|
try { |
112
|
|
|
return $this->innerGateway->updateContent($contentId, $struct, $prePublishVersionInfo); |
113
|
|
|
} catch (DBALException $e) { |
114
|
|
|
throw new RuntimeException('Database error', 0, $e); |
115
|
|
|
} catch (PDOException $e) { |
116
|
|
|
throw new RuntimeException('Database error', 0, $e); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Updates version $versionNo for content identified by $contentId, in respect to $struct. |
122
|
|
|
* |
123
|
|
|
* @param int $contentId |
124
|
|
|
* @param int $versionNo |
125
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\UpdateStruct $struct |
126
|
|
|
*/ |
127
|
|
|
public function updateVersion($contentId, $versionNo, UpdateStruct $struct) |
128
|
|
|
{ |
129
|
|
|
try { |
130
|
|
|
return $this->innerGateway->updateVersion($contentId, $versionNo, $struct); |
131
|
|
|
} catch (DBALException $e) { |
132
|
|
|
throw new RuntimeException('Database error', 0, $e); |
133
|
|
|
} catch (PDOException $e) { |
134
|
|
|
throw new RuntimeException('Database error', 0, $e); |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Updates "always available" flag for content identified by $contentId, in respect to $alwaysAvailable. |
140
|
|
|
* |
141
|
|
|
* @param int $contentId |
142
|
|
|
* @param bool $newAlwaysAvailable New "always available" value |
143
|
|
|
*/ |
144
|
|
|
public function updateAlwaysAvailableFlag($contentId, $newAlwaysAvailable) |
145
|
|
|
{ |
146
|
|
|
try { |
147
|
|
|
return $this->innerGateway->updateAlwaysAvailableFlag($contentId, $newAlwaysAvailable); |
148
|
|
|
} catch (DBALException $e) { |
149
|
|
|
throw new RuntimeException('Database error', 0, $e); |
150
|
|
|
} catch (PDOException $e) { |
151
|
|
|
throw new RuntimeException('Database error', 0, $e); |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Sets the state of object identified by $contentId and $version to $state. |
157
|
|
|
* |
158
|
|
|
* The $status can be one of STATUS_DRAFT, STATUS_PUBLISHED, STATUS_ARCHIVED |
159
|
|
|
* |
160
|
|
|
* @param int $contentId |
161
|
|
|
* @param int $version |
162
|
|
|
* @param int $status |
163
|
|
|
* |
164
|
|
|
* @return bool |
165
|
|
|
*/ |
166
|
|
|
public function setStatus($contentId, $version, $status) |
167
|
|
|
{ |
168
|
|
|
try { |
169
|
|
|
return $this->innerGateway->setStatus($contentId, $version, $status); |
170
|
|
|
} catch (DBALException $e) { |
171
|
|
|
throw new RuntimeException('Database error', 0, $e); |
172
|
|
|
} catch (PDOException $e) { |
173
|
|
|
throw new RuntimeException('Database error', 0, $e); |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Inserts a new field. |
179
|
|
|
* |
180
|
|
|
* Only used when a new field is created (i.e. a new object or a field in a |
181
|
|
|
* new language!). After that, field IDs need to stay the same, only the |
182
|
|
|
* version number changes. |
183
|
|
|
* |
184
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content $content |
185
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\Field $field |
186
|
|
|
* @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value |
187
|
|
|
* |
188
|
|
|
* @return int ID |
189
|
|
|
*/ |
190
|
|
View Code Duplication |
public function insertNewField(Content $content, Field $field, StorageFieldValue $value) |
191
|
|
|
{ |
192
|
|
|
try { |
193
|
|
|
return $this->innerGateway->insertNewField($content, $field, $value); |
194
|
|
|
} catch (DBALException $e) { |
195
|
|
|
throw new RuntimeException('Database error', 0, $e); |
196
|
|
|
} catch (PDOException $e) { |
197
|
|
|
throw new RuntimeException('Database error', 0, $e); |
198
|
|
|
} |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Inserts an existing field. |
203
|
|
|
* |
204
|
|
|
* Used to insert a field with an exsting ID but a new version number. |
205
|
|
|
* |
206
|
|
|
* @param Content $content |
207
|
|
|
* @param Field $field |
208
|
|
|
* @param StorageFieldValue $value |
209
|
|
|
*/ |
210
|
|
View Code Duplication |
public function insertExistingField(Content $content, Field $field, StorageFieldValue $value) |
211
|
|
|
{ |
212
|
|
|
try { |
213
|
|
|
return $this->innerGateway->insertExistingField($content, $field, $value); |
214
|
|
|
} catch (DBALException $e) { |
215
|
|
|
throw new RuntimeException('Database error', 0, $e); |
216
|
|
|
} catch (PDOException $e) { |
217
|
|
|
throw new RuntimeException('Database error', 0, $e); |
218
|
|
|
} |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Updates an existing field. |
223
|
|
|
* |
224
|
|
|
* @param Field $field |
225
|
|
|
* @param StorageFieldValue $value |
226
|
|
|
*/ |
227
|
|
View Code Duplication |
public function updateField(Field $field, StorageFieldValue $value) |
228
|
|
|
{ |
229
|
|
|
try { |
230
|
|
|
return $this->innerGateway->updateField($field, $value); |
231
|
|
|
} catch (DBALException $e) { |
232
|
|
|
throw new RuntimeException('Database error', 0, $e); |
233
|
|
|
} catch (PDOException $e) { |
234
|
|
|
throw new RuntimeException('Database error', 0, $e); |
235
|
|
|
} |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* Updates an existing, non-translatable field. |
240
|
|
|
* |
241
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\Field $field |
242
|
|
|
* @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value |
243
|
|
|
* @param int $contentId |
244
|
|
|
*/ |
245
|
|
View Code Duplication |
public function updateNonTranslatableField( |
246
|
|
|
Field $field, |
247
|
|
|
StorageFieldValue $value, |
248
|
|
|
$contentId |
249
|
|
|
) { |
250
|
|
|
try { |
251
|
|
|
return $this->innerGateway->updateNonTranslatableField($field, $value, $contentId); |
252
|
|
|
} catch (DBALException $e) { |
253
|
|
|
throw new RuntimeException('Database error', 0, $e); |
254
|
|
|
} catch (PDOException $e) { |
255
|
|
|
throw new RuntimeException('Database error', 0, $e); |
256
|
|
|
} |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* Loads data for a content object. |
261
|
|
|
* |
262
|
|
|
* Returns an array with the relevant data. |
263
|
|
|
* |
264
|
|
|
* @param mixed $contentId |
265
|
|
|
* @param mixed $version |
266
|
|
|
* @param string[] $translations |
267
|
|
|
* |
268
|
|
|
* @return array |
269
|
|
|
*/ |
270
|
|
|
public function load($contentId, $version, array $translations = null) |
271
|
|
|
{ |
272
|
|
|
try { |
273
|
|
|
return $this->innerGateway->load($contentId, $version, $translations); |
274
|
|
|
} catch (DBALException $e) { |
275
|
|
|
throw new RuntimeException('Database error', 0, $e); |
276
|
|
|
} catch (PDOException $e) { |
277
|
|
|
throw new RuntimeException('Database error', 0, $e); |
278
|
|
|
} |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* Loads data for a content object identified by its remote ID. |
283
|
|
|
* |
284
|
|
|
* Returns an array with the relevant data. |
285
|
|
|
* |
286
|
|
|
* @param mixed $remoteId |
287
|
|
|
* |
288
|
|
|
* @return array |
289
|
|
|
*/ |
290
|
|
|
public function loadContentInfoByRemoteId($remoteId) |
291
|
|
|
{ |
292
|
|
|
try { |
293
|
|
|
return $this->innerGateway->loadContentInfoByRemoteId($remoteId); |
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
|
|
|
* Loads info for content identified by $contentId. |
303
|
|
|
* Will basically return a hash containing all field values for ezcontentobject table plus following keys: |
304
|
|
|
* - always_available => Boolean indicating if content's language mask contains alwaysAvailable bit field |
305
|
|
|
* - main_language_code => Language code for main (initial) language. E.g. "eng-GB". |
306
|
|
|
* |
307
|
|
|
* @param int $contentId |
308
|
|
|
* |
309
|
|
|
* @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException |
310
|
|
|
* |
311
|
|
|
* @return array |
312
|
|
|
*/ |
313
|
|
|
public function loadContentInfo($contentId) |
314
|
|
|
{ |
315
|
|
|
try { |
316
|
|
|
return $this->innerGateway->loadContentInfo($contentId); |
317
|
|
|
} catch (DBALException $e) { |
318
|
|
|
throw new RuntimeException('Database error', 0, $e); |
319
|
|
|
} catch (PDOException $e) { |
320
|
|
|
throw new RuntimeException('Database error', 0, $e); |
321
|
|
|
} |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* Loads version info for content identified by $contentId and $versionNo. |
326
|
|
|
* Will basically return a hash containing all field values from ezcontentobject_version table plus following keys: |
327
|
|
|
* - names => Hash of content object names. Key is the language code, value is the name. |
328
|
|
|
* - languages => Hash of language ids. Key is the language code (e.g. "eng-GB"), value is the language numeric id without the always available bit. |
329
|
|
|
* - initial_language_code => Language code for initial language in this version. |
330
|
|
|
* |
331
|
|
|
* @param int $contentId |
332
|
|
|
* @param int $versionNo |
333
|
|
|
* |
334
|
|
|
* @return array |
335
|
|
|
*/ |
336
|
|
|
public function loadVersionInfo($contentId, $versionNo) |
337
|
|
|
{ |
338
|
|
|
try { |
339
|
|
|
return $this->innerGateway->loadVersionInfo($contentId, $versionNo); |
340
|
|
|
} catch (DBALException $e) { |
341
|
|
|
throw new RuntimeException('Database error', 0, $e); |
342
|
|
|
} catch (PDOException $e) { |
343
|
|
|
throw new RuntimeException('Database error', 0, $e); |
344
|
|
|
} |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* Returns data for all versions with given status created by the given $userId. |
349
|
|
|
* |
350
|
|
|
* @param int $userId |
351
|
|
|
* @param int $status |
352
|
|
|
* |
353
|
|
|
* @return string[][] |
354
|
|
|
*/ |
355
|
|
|
public function listVersionsForUser($userId, $status = VersionInfo::STATUS_DRAFT) |
356
|
|
|
{ |
357
|
|
|
try { |
358
|
|
|
return $this->innerGateway->listVersionsForUser($userId, $status); |
359
|
|
|
} catch (DBALException $e) { |
360
|
|
|
throw new RuntimeException('Database error', 0, $e); |
361
|
|
|
} catch (PDOException $e) { |
362
|
|
|
throw new RuntimeException('Database error', 0, $e); |
363
|
|
|
} |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
/** |
367
|
|
|
* Returns all version data for the given $contentId. |
368
|
|
|
* |
369
|
|
|
* @param mixed $contentId |
370
|
|
|
* |
371
|
|
|
* @return string[][] |
372
|
|
|
*/ |
373
|
|
|
public function listVersions($contentId) |
374
|
|
|
{ |
375
|
|
|
try { |
376
|
|
|
return $this->innerGateway->listVersions($contentId); |
377
|
|
|
} catch (DBALException $e) { |
378
|
|
|
throw new RuntimeException('Database error', 0, $e); |
379
|
|
|
} catch (PDOException $e) { |
380
|
|
|
throw new RuntimeException('Database error', 0, $e); |
381
|
|
|
} |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* Returns all version numbers for the given $contentId. |
386
|
|
|
* |
387
|
|
|
* @param mixed $contentId |
388
|
|
|
* |
389
|
|
|
* @return int[] |
390
|
|
|
*/ |
391
|
|
|
public function listVersionNumbers($contentId) |
392
|
|
|
{ |
393
|
|
|
try { |
394
|
|
|
return $this->innerGateway->listVersionNumbers($contentId); |
395
|
|
|
} catch (DBALException $e) { |
396
|
|
|
throw new RuntimeException('Database error', 0, $e); |
397
|
|
|
} catch (PDOException $e) { |
398
|
|
|
throw new RuntimeException('Database error', 0, $e); |
399
|
|
|
} |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* Returns last version number for content identified by $contentId. |
404
|
|
|
* |
405
|
|
|
* @param int $contentId |
406
|
|
|
* |
407
|
|
|
* @return int |
408
|
|
|
*/ |
409
|
|
|
public function getLastVersionNumber($contentId) |
410
|
|
|
{ |
411
|
|
|
try { |
412
|
|
|
return $this->innerGateway->getLastVersionNumber($contentId); |
413
|
|
|
} catch (DBALException $e) { |
414
|
|
|
throw new RuntimeException('Database error', 0, $e); |
415
|
|
|
} catch (PDOException $e) { |
416
|
|
|
throw new RuntimeException('Database error', 0, $e); |
417
|
|
|
} |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* Returns all IDs for locations that refer to $contentId. |
422
|
|
|
* |
423
|
|
|
* @param int $contentId |
424
|
|
|
* |
425
|
|
|
* @return int[] |
426
|
|
|
*/ |
427
|
|
|
public function getAllLocationIds($contentId) |
428
|
|
|
{ |
429
|
|
|
try { |
430
|
|
|
return $this->innerGateway->getAllLocationIds($contentId); |
431
|
|
|
} catch (DBALException $e) { |
432
|
|
|
throw new RuntimeException('Database error', 0, $e); |
433
|
|
|
} catch (PDOException $e) { |
434
|
|
|
throw new RuntimeException('Database error', 0, $e); |
435
|
|
|
} |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* Returns all field IDs of $contentId grouped by their type. |
440
|
|
|
* If $versionNo is set only field IDs for that version are returned. |
441
|
|
|
* |
442
|
|
|
* @param int $contentId |
443
|
|
|
* @param int|null $versionNo |
444
|
|
|
* |
445
|
|
|
* @return int[][] |
446
|
|
|
*/ |
447
|
|
|
public function getFieldIdsByType($contentId, $versionNo = null) |
448
|
|
|
{ |
449
|
|
|
try { |
450
|
|
|
return $this->innerGateway->getFieldIdsByType($contentId, $versionNo); |
451
|
|
|
} catch (DBALException $e) { |
452
|
|
|
throw new RuntimeException('Database error', 0, $e); |
453
|
|
|
} catch (PDOException $e) { |
454
|
|
|
throw new RuntimeException('Database error', 0, $e); |
455
|
|
|
} |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
/** |
459
|
|
|
* Deletes relations to and from $contentId. |
460
|
|
|
* If $versionNo is set only relations for that version are deleted. |
461
|
|
|
* |
462
|
|
|
* @param int $contentId |
463
|
|
|
* @param int|null $versionNo |
464
|
|
|
*/ |
465
|
|
|
public function deleteRelations($contentId, $versionNo = null) |
466
|
|
|
{ |
467
|
|
|
try { |
468
|
|
|
return $this->innerGateway->deleteRelations($contentId, $versionNo); |
469
|
|
|
} catch (DBALException $e) { |
470
|
|
|
throw new RuntimeException('Database error', 0, $e); |
471
|
|
|
} catch (PDOException $e) { |
472
|
|
|
throw new RuntimeException('Database error', 0, $e); |
473
|
|
|
} |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* Removes relations to Content with $contentId from Relation and RelationList field type fields. |
478
|
|
|
* |
479
|
|
|
* @param int $contentId |
480
|
|
|
*/ |
481
|
|
|
public function removeReverseFieldRelations($contentId) |
482
|
|
|
{ |
483
|
|
|
try { |
484
|
|
|
return $this->innerGateway->removeReverseFieldRelations($contentId); |
485
|
|
|
} catch (DBALException $e) { |
486
|
|
|
throw new RuntimeException('Database error', 0, $e); |
487
|
|
|
} catch (PDOException $e) { |
488
|
|
|
throw new RuntimeException('Database error', 0, $e); |
489
|
|
|
} |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
/** |
493
|
|
|
* Deletes the field with the given $fieldId. |
494
|
|
|
* |
495
|
|
|
* @param int $fieldId |
496
|
|
|
*/ |
497
|
|
|
public function deleteField($fieldId) |
498
|
|
|
{ |
499
|
|
|
try { |
500
|
|
|
return $this->innerGateway->deleteField($fieldId); |
501
|
|
|
} catch (DBALException $e) { |
502
|
|
|
throw new RuntimeException('Database error', 0, $e); |
503
|
|
|
} catch (PDOException $e) { |
504
|
|
|
throw new RuntimeException('Database error', 0, $e); |
505
|
|
|
} |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
/** |
509
|
|
|
* Deletes all fields of $contentId in all versions. |
510
|
|
|
* If $versionNo is set only fields for that version are deleted. |
511
|
|
|
* |
512
|
|
|
* @param int $contentId |
513
|
|
|
* @param int|null $versionNo |
514
|
|
|
*/ |
515
|
|
|
public function deleteFields($contentId, $versionNo = null) |
516
|
|
|
{ |
517
|
|
|
try { |
518
|
|
|
return $this->innerGateway->deleteFields($contentId, $versionNo); |
519
|
|
|
} catch (DBALException $e) { |
520
|
|
|
throw new RuntimeException('Database error', 0, $e); |
521
|
|
|
} catch (PDOException $e) { |
522
|
|
|
throw new RuntimeException('Database error', 0, $e); |
523
|
|
|
} |
524
|
|
|
} |
525
|
|
|
|
526
|
|
|
/** |
527
|
|
|
* Deletes all versions of $contentId. |
528
|
|
|
* If $versionNo is set only that version is deleted. |
529
|
|
|
* |
530
|
|
|
* @param int $contentId |
531
|
|
|
* @param int|null $versionNo |
532
|
|
|
*/ |
533
|
|
|
public function deleteVersions($contentId, $versionNo = null) |
534
|
|
|
{ |
535
|
|
|
try { |
536
|
|
|
return $this->innerGateway->deleteVersions($contentId, $versionNo); |
537
|
|
|
} catch (DBALException $e) { |
538
|
|
|
throw new RuntimeException('Database error', 0, $e); |
539
|
|
|
} catch (PDOException $e) { |
540
|
|
|
throw new RuntimeException('Database error', 0, $e); |
541
|
|
|
} |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* Deletes all names of $contentId. |
546
|
|
|
* If $versionNo is set only names for that version are deleted. |
547
|
|
|
* |
548
|
|
|
* @param int $contentId |
549
|
|
|
* @param int|null $versionNo |
550
|
|
|
*/ |
551
|
|
|
public function deleteNames($contentId, $versionNo = null) |
552
|
|
|
{ |
553
|
|
|
try { |
554
|
|
|
return $this->innerGateway->deleteNames($contentId, $versionNo); |
555
|
|
|
} catch (DBALException $e) { |
556
|
|
|
throw new RuntimeException('Database error', 0, $e); |
557
|
|
|
} catch (PDOException $e) { |
558
|
|
|
throw new RuntimeException('Database error', 0, $e); |
559
|
|
|
} |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
/** |
563
|
|
|
* Sets the content object name. |
564
|
|
|
* |
565
|
|
|
* @param int $contentId |
566
|
|
|
* @param int $version |
567
|
|
|
* @param string $name |
568
|
|
|
* @param string $language |
569
|
|
|
*/ |
570
|
|
|
public function setName($contentId, $version, $name, $language) |
571
|
|
|
{ |
572
|
|
|
try { |
573
|
|
|
return $this->innerGateway->setName($contentId, $version, $name, $language); |
574
|
|
|
} catch (DBALException $e) { |
575
|
|
|
throw new RuntimeException('Database error', 0, $e); |
576
|
|
|
} catch (PDOException $e) { |
577
|
|
|
throw new RuntimeException('Database error', 0, $e); |
578
|
|
|
} |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
/** |
582
|
|
|
* Deletes the actual content object referred to by $contentId. |
583
|
|
|
* |
584
|
|
|
* @param int $contentId |
585
|
|
|
*/ |
586
|
|
|
public function deleteContent($contentId) |
587
|
|
|
{ |
588
|
|
|
try { |
589
|
|
|
return $this->innerGateway->deleteContent($contentId); |
590
|
|
|
} catch (DBALException $e) { |
591
|
|
|
throw new RuntimeException('Database error', 0, $e); |
592
|
|
|
} catch (PDOException $e) { |
593
|
|
|
throw new RuntimeException('Database error', 0, $e); |
594
|
|
|
} |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
/** |
598
|
|
|
* Loads data of related to/from $contentId. |
599
|
|
|
* |
600
|
|
|
* @param int $contentId |
601
|
|
|
* @param int $contentVersionNo |
602
|
|
|
* @param int $relationType |
603
|
|
|
* |
604
|
|
|
* @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()} |
605
|
|
|
*/ |
606
|
|
|
public function loadRelations($contentId, $contentVersionNo = null, $relationType = null) |
607
|
|
|
{ |
608
|
|
|
try { |
609
|
|
|
return $this->innerGateway->loadRelations($contentId, $contentVersionNo, $relationType); |
610
|
|
|
} catch (DBALException $e) { |
611
|
|
|
throw new RuntimeException('Database error', 0, $e); |
612
|
|
|
} catch (PDOException $e) { |
613
|
|
|
throw new RuntimeException('Database error', 0, $e); |
614
|
|
|
} |
615
|
|
|
} |
616
|
|
|
|
617
|
|
|
/** |
618
|
|
|
* Loads data of related to/from $contentId. |
619
|
|
|
* |
620
|
|
|
* @param int $contentId |
621
|
|
|
* @param bool $reverse Reverse relation, default false |
|
|
|
|
622
|
|
|
* @param int $contentVersionNo |
|
|
|
|
623
|
|
|
* @param int $relationType |
624
|
|
|
* |
625
|
|
|
* @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()} |
626
|
|
|
*/ |
627
|
|
|
public function loadReverseRelations($contentId, $relationType = null) |
628
|
|
|
{ |
629
|
|
|
try { |
630
|
|
|
return $this->innerGateway->loadReverseRelations($contentId, $relationType); |
631
|
|
|
} catch (DBALException $e) { |
632
|
|
|
throw new RuntimeException('Database error', 0, $e); |
633
|
|
|
} catch (PDOException $e) { |
634
|
|
|
throw new RuntimeException('Database error', 0, $e); |
635
|
|
|
} |
636
|
|
|
} |
637
|
|
|
|
638
|
|
|
/** |
639
|
|
|
* Deletes the relation with the given $relationId. |
640
|
|
|
* |
641
|
|
|
* @param int $relationId |
642
|
|
|
* @param int $type {@see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON, |
643
|
|
|
* \eZ\Publish\API\Repository\Values\Content\Relation::EMBED, |
644
|
|
|
* \eZ\Publish\API\Repository\Values\Content\Relation::LINK, |
645
|
|
|
* \eZ\Publish\API\Repository\Values\Content\Relation::FIELD} |
646
|
|
|
*/ |
647
|
|
|
public function deleteRelation($relationId, $type) |
648
|
|
|
{ |
649
|
|
|
try { |
650
|
|
|
return $this->innerGateway->deleteRelation($relationId, $type); |
651
|
|
|
} catch (DBALException $e) { |
652
|
|
|
throw new RuntimeException('Database error', 0, $e); |
653
|
|
|
} catch (PDOException $e) { |
654
|
|
|
throw new RuntimeException('Database error', 0, $e); |
655
|
|
|
} |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
/** |
659
|
|
|
* Inserts a new relation database record. |
660
|
|
|
* |
661
|
|
|
* @param \eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct $createStruct |
|
|
|
|
662
|
|
|
* |
663
|
|
|
* @return int ID the inserted ID |
664
|
|
|
*/ |
665
|
|
|
public function insertRelation(RelationCreateStruct $struct) |
666
|
|
|
{ |
667
|
|
|
try { |
668
|
|
|
return $this->innerGateway->insertRelation($struct); |
669
|
|
|
} catch (DBALException $e) { |
670
|
|
|
throw new RuntimeException('Database error', 0, $e); |
671
|
|
|
} catch (PDOException $e) { |
672
|
|
|
throw new RuntimeException('Database error', 0, $e); |
673
|
|
|
} |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* Returns all Content IDs for a given $contentTypeId. |
678
|
|
|
* |
679
|
|
|
* @param int $contentTypeId |
680
|
|
|
* |
681
|
|
|
* @return int[] |
682
|
|
|
*/ |
683
|
|
|
public function getContentIdsByContentTypeId($contentTypeId) |
684
|
|
|
{ |
685
|
|
|
try { |
686
|
|
|
return $this->innerGateway->getContentIdsByContentTypeId($contentTypeId); |
687
|
|
|
} catch (DBALException $e) { |
688
|
|
|
throw new RuntimeException('Database error', 0, $e); |
689
|
|
|
} catch (PDOException $e) { |
690
|
|
|
throw new RuntimeException('Database error', 0, $e); |
691
|
|
|
} |
692
|
|
|
} |
693
|
|
|
|
694
|
|
|
/** |
695
|
|
|
* Load name data for set of content id's and corresponding version number. |
696
|
|
|
* |
697
|
|
|
* @param array[] $rows array of hashes with 'id' and 'version' to load names for |
698
|
|
|
* |
699
|
|
|
* @return array |
700
|
|
|
*/ |
701
|
|
|
public function loadVersionedNameData($rows) |
702
|
|
|
{ |
703
|
|
|
try { |
704
|
|
|
return $this->innerGateway->loadVersionedNameData($rows); |
705
|
|
|
} catch (DBALException $e) { |
706
|
|
|
throw new RuntimeException('Database error', 0, $e); |
707
|
|
|
} catch (PDOException $e) { |
708
|
|
|
throw new RuntimeException('Database error', 0, $e); |
709
|
|
|
} |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
/** |
713
|
|
|
* Batch method for copying all relation meta data for copied Content object. |
714
|
|
|
* |
715
|
|
|
* {@inheritdoc} |
716
|
|
|
* |
717
|
|
|
* @param int $originalContentId |
718
|
|
|
* @param int $copiedContentId |
719
|
|
|
* @param int|null $versionNo If specified only copy for a given version number, otherwise all. |
720
|
|
|
*/ |
721
|
|
View Code Duplication |
public function copyRelations($originalContentId, $copiedContentId, $versionNo = null) |
722
|
|
|
{ |
723
|
|
|
try { |
724
|
|
|
return $this->innerGateway->copyRelations($originalContentId, $copiedContentId, $versionNo); |
725
|
|
|
} catch (DBALException $e) { |
726
|
|
|
throw new RuntimeException('Database error', 0, $e); |
727
|
|
|
} catch (PDOException $e) { |
728
|
|
|
throw new RuntimeException('Database error', 0, $e); |
729
|
|
|
} |
730
|
|
|
} |
731
|
|
|
} |
732
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.