Completed
Push — location_content_property ( b180d5 )
by André
16:28
created

ExceptionConversion::loadContentList()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
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
namespace eZ\Publish\Core\Persistence\Legacy\Content\Gateway;
10
11
use eZ\Publish\Core\Persistence\Legacy\Content\Gateway;
12
use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue;
13
use eZ\Publish\SPI\Persistence\Content;
14
use eZ\Publish\SPI\Persistence\Content\CreateStruct;
15
use eZ\Publish\SPI\Persistence\Content\UpdateStruct;
16
use eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct;
17
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
18
use eZ\Publish\SPI\Persistence\Content\Field;
19
use eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct as RelationCreateStruct;
20
use Doctrine\DBAL\DBALException;
21
use PDOException;
22
use RuntimeException;
23
24
/**
25
 * Base class for content gateways.
26
 */
27
class ExceptionConversion extends Gateway
28
{
29
    /**
30
     * The wrapped gateway.
31
     *
32
     * @var Gateway
33
     */
34
    protected $innerGateway;
35
36
    /**
37
     * Creates a new exception conversion gateway around $innerGateway.
38
     *
39
     * @param Gateway $innerGateway
40
     */
41
    public function __construct(Gateway $innerGateway)
42
    {
43
        $this->innerGateway = $innerGateway;
44
    }
45
46
    /**
47
     * Get context definition for external storage layers.
48
     *
49
     * @return array
50
     */
51
    public function getContext()
52
    {
53
        try {
54
            return $this->innerGateway->getContext();
55
        } catch (DBALException $e) {
56
            throw new RuntimeException('Database error', 0, $e);
57
        } catch (PDOException $e) {
58
            throw new RuntimeException('Database error', 0, $e);
59
        }
60
    }
61
62
    /**
63
     * Inserts a new content object.
64
     *
65
     * @param \eZ\Publish\SPI\Persistence\Content\CreateStruct $struct
66
     * @param mixed $currentVersionNo
67
     *
68
     * @return int ID
69
     */
70
    public function insertContentObject(CreateStruct $struct, $currentVersionNo = 1)
71
    {
72
        try {
73
            return $this->innerGateway->insertContentObject($struct, $currentVersionNo);
74
        } catch (DBALException $e) {
75
            throw new RuntimeException('Database error', 0, $e);
76
        } catch (PDOException $e) {
77
            throw new RuntimeException('Database error', 0, $e);
78
        }
79
    }
80
81
    /**
82
     * Inserts a new version.
83
     *
84
     * @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo
85
     * @param \eZ\Publish\SPI\Persistence\Content\Field[] $fields
86
     *
87
     * @return int ID
88
     */
89
    public function insertVersion(VersionInfo $versionInfo, array $fields)
90
    {
91
        try {
92
            return $this->innerGateway->insertVersion($versionInfo, $fields);
93
        } catch (DBALException $e) {
94
            throw new RuntimeException('Database error', 0, $e);
95
        } catch (PDOException $e) {
96
            throw new RuntimeException('Database error', 0, $e);
97
        }
98
    }
99
100
    /**
101
     * Updates an existing content identified by $contentId in respect to $struct.
102
     *
103
     * @param int $contentId
104
     * @param \eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct $struct
105
     * @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $prePublishVersionInfo Provided on publish
106
     */
107
    public function updateContent($contentId, MetadataUpdateStruct $struct, VersionInfo $prePublishVersionInfo = null)
108
    {
109
        try {
110
            return $this->innerGateway->updateContent($contentId, $struct, $prePublishVersionInfo);
111
        } catch (DBALException $e) {
112
            throw new RuntimeException('Database error', 0, $e);
113
        } catch (PDOException $e) {
114
            throw new RuntimeException('Database error', 0, $e);
115
        }
116
    }
117
118
    /**
119
     * Updates version $versionNo for content identified by $contentId, in respect to $struct.
120
     *
121
     * @param int $contentId
122
     * @param int $versionNo
123
     * @param \eZ\Publish\SPI\Persistence\Content\UpdateStruct $struct
124
     */
125
    public function updateVersion($contentId, $versionNo, UpdateStruct $struct)
126
    {
127
        try {
128
            return $this->innerGateway->updateVersion($contentId, $versionNo, $struct);
129
        } catch (DBALException $e) {
130
            throw new RuntimeException('Database error', 0, $e);
131
        } catch (PDOException $e) {
132
            throw new RuntimeException('Database error', 0, $e);
133
        }
134
    }
135
136
    /**
137
     * Updates "always available" flag for content identified by $contentId, in respect to $alwaysAvailable.
138
     *
139
     * @param int $contentId
140
     * @param bool $newAlwaysAvailable New "always available" value
141
     */
142
    public function updateAlwaysAvailableFlag($contentId, $newAlwaysAvailable)
143
    {
144
        try {
145
            return $this->innerGateway->updateAlwaysAvailableFlag($contentId, $newAlwaysAvailable);
146
        } catch (DBALException $e) {
147
            throw new RuntimeException('Database error', 0, $e);
148
        } catch (PDOException $e) {
149
            throw new RuntimeException('Database error', 0, $e);
150
        }
151
    }
152
153
    /**
154
     * Sets the state of object identified by $contentId and $version to $state.
155
     *
156
     * The $status can be one of STATUS_DRAFT, STATUS_PUBLISHED, STATUS_ARCHIVED
157
     *
158
     * @param int $contentId
159
     * @param int $version
160
     * @param int $status
161
     *
162
     * @return bool
163
     */
164
    public function setStatus($contentId, $version, $status)
165
    {
166
        try {
167
            return $this->innerGateway->setStatus($contentId, $version, $status);
168
        } catch (DBALException $e) {
169
            throw new RuntimeException('Database error', 0, $e);
170
        } catch (PDOException $e) {
171
            throw new RuntimeException('Database error', 0, $e);
172
        }
173
    }
174
175
    /**
176
     * Inserts a new field.
177
     *
178
     * Only used when a new field is created (i.e. a new object or a field in a
179
     * new language!). After that, field IDs need to stay the same, only the
180
     * version number changes.
181
     *
182
     * @param \eZ\Publish\SPI\Persistence\Content $content
183
     * @param \eZ\Publish\SPI\Persistence\Content\Field $field
184
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value
185
     *
186
     * @return int ID
187
     */
188
    public function insertNewField(Content $content, Field $field, StorageFieldValue $value)
189
    {
190
        try {
191
            return $this->innerGateway->insertNewField($content, $field, $value);
192
        } catch (DBALException $e) {
193
            throw new RuntimeException('Database error', 0, $e);
194
        } catch (PDOException $e) {
195
            throw new RuntimeException('Database error', 0, $e);
196
        }
197
    }
198
199
    /**
200
     * Inserts an existing field.
201
     *
202
     * Used to insert a field with an exsting ID but a new version number.
203
     *
204
     * @param Content $content
205
     * @param Field $field
206
     * @param StorageFieldValue $value
207
     */
208
    public function insertExistingField(Content $content, Field $field, StorageFieldValue $value)
209
    {
210
        try {
211
            return $this->innerGateway->insertExistingField($content, $field, $value);
212
        } catch (DBALException $e) {
213
            throw new RuntimeException('Database error', 0, $e);
214
        } catch (PDOException $e) {
215
            throw new RuntimeException('Database error', 0, $e);
216
        }
217
    }
218
219
    /**
220
     * Updates an existing field.
221
     *
222
     * @param Field $field
223
     * @param StorageFieldValue $value
224
     */
225
    public function updateField(Field $field, StorageFieldValue $value)
226
    {
227
        try {
228
            return $this->innerGateway->updateField($field, $value);
229
        } catch (DBALException $e) {
230
            throw new RuntimeException('Database error', 0, $e);
231
        } catch (PDOException $e) {
232
            throw new RuntimeException('Database error', 0, $e);
233
        }
234
    }
235
236
    /**
237
     * Updates an existing, non-translatable field.
238
     *
239
     * @param \eZ\Publish\SPI\Persistence\Content\Field $field
240
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value
241
     * @param int $contentId
242
     */
243
    public function updateNonTranslatableField(
244
        Field $field,
245
        StorageFieldValue $value,
246
        $contentId
247
    ) {
248
        try {
249
            return $this->innerGateway->updateNonTranslatableField($field, $value, $contentId);
250
        } catch (DBALException $e) {
251
            throw new RuntimeException('Database error', 0, $e);
252
        } catch (PDOException $e) {
253
            throw new RuntimeException('Database error', 0, $e);
254
        }
255
    }
256
257
    /**
258
     * Loads data for a content object.
259
     *
260
     * Returns an array with the relevant data.
261
     *
262
     * @param mixed $contentId
263
     * @param mixed $version
264
     * @param string[] $translations
265
     *
266
     * @return array
267
     */
268
    public function load($contentId, $version, array $translations = null)
269
    {
270
        try {
271
            return $this->innerGateway->load($contentId, $version, $translations);
272
        } catch (DBALException $e) {
273
            throw new RuntimeException('Database error', 0, $e);
274
        } catch (PDOException $e) {
275
            throw new RuntimeException('Database error', 0, $e);
276
        }
277
    }
278
279
    /**
280
     * {@inheritdoc}
281
     */
282
    public function loadContentList(array $IdVersionTranslationPairs): array
283
    {
284
        try {
285
            return $this->innerGateway->loadContentList($IdVersionTranslationPairs);
286
        } catch (DBALException | PDOException $e) {
287
            throw new RuntimeException('Database error', 0, $e);
288
        }
289
    }
290
291
    /**
292
     * Loads data for a content object identified by its remote ID.
293
     *
294
     * Returns an array with the relevant data.
295
     *
296
     * @param mixed $remoteId
297
     *
298
     * @return array
299
     */
300
    public function loadContentInfoByRemoteId($remoteId)
301
    {
302
        try {
303
            return $this->innerGateway->loadContentInfoByRemoteId($remoteId);
304
        } catch (DBALException $e) {
305
            throw new \RuntimeException('Database error', 0, $e);
306
        } catch (\PDOException $e) {
307
            throw new \RuntimeException('Database error', 0, $e);
308
        }
309
    }
310
311
    /**
312
     * Loads info for content identified by $contentId.
313
     * Will basically return a hash containing all field values for ezcontentobject table plus following keys:
314
     *  - always_available => Boolean indicating if content's language mask contains alwaysAvailable bit field
315
     *  - main_language_code => Language code for main (initial) language. E.g. "eng-GB".
316
     *
317
     * @param int $contentId
318
     *
319
     * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException
320
     *
321
     * @return array
322
     */
323
    public function loadContentInfo($contentId)
324
    {
325
        try {
326
            return $this->innerGateway->loadContentInfo($contentId);
327
        } catch (DBALException $e) {
328
            throw new RuntimeException('Database error', 0, $e);
329
        } catch (PDOException $e) {
330
            throw new RuntimeException('Database error', 0, $e);
331
        }
332
    }
333
334
    public function loadContentInfoList(array $contentIds)
335
    {
336
        try {
337
            return $this->innerGateway->loadContentInfoList($contentIds);
338
        } catch (DBALException $e) {
339
            throw new RuntimeException('Database error', 0, $e);
340
        } catch (PDOException $e) {
341
            throw new RuntimeException('Database error', 0, $e);
342
        }
343
    }
344
345
    /**
346
     * Loads version info for content identified by $contentId and $versionNo.
347
     * Will basically return a hash containing all field values from ezcontentobject_version table plus following keys:
348
     *  - names => Hash of content object names. Key is the language code, value is the name.
349
     *  - 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.
350
     *  - initial_language_code => Language code for initial language in this version.
351
     *
352
     * @param int $contentId
353
     * @param int $versionNo
354
     *
355
     * @return array
356
     */
357
    public function loadVersionInfo($contentId, $versionNo)
358
    {
359
        try {
360
            return $this->innerGateway->loadVersionInfo($contentId, $versionNo);
361
        } catch (DBALException $e) {
362
            throw new RuntimeException('Database error', 0, $e);
363
        } catch (PDOException $e) {
364
            throw new RuntimeException('Database error', 0, $e);
365
        }
366
    }
367
368
    /**
369
     * Returns data for all versions with given status created by the given $userId.
370
     *
371
     * @param int $userId
372
     * @param int $status
373
     *
374
     * @return string[][]
375
     */
376
    public function listVersionsForUser($userId, $status = VersionInfo::STATUS_DRAFT)
377
    {
378
        try {
379
            return $this->innerGateway->listVersionsForUser($userId, $status);
380
        } catch (DBALException $e) {
381
            throw new RuntimeException('Database error', 0, $e);
382
        } catch (PDOException $e) {
383
            throw new RuntimeException('Database error', 0, $e);
384
        }
385
    }
386
387
    /**
388
     * Returns all version data for the given $contentId.
389
     *
390
     * Result is returned with oldest version first (using version id as it has index and is auto increment).
391
     *
392
     * @param mixed $contentId
393
     * @param mixed|null $status Optional argument to filter versions by status, like {@see VersionInfo::STATUS_ARCHIVED}.
394
     * @param int $limit Limit for items returned, -1 means none.
395
     *
396
     * @return string[][]
397
     */
398
    public function listVersions($contentId, $status = null, $limit = -1)
399
    {
400
        try {
401
            return $this->innerGateway->listVersions($contentId, $status, $limit);
402
        } catch (DBALException $e) {
403
            throw new RuntimeException('Database error', 0, $e);
404
        } catch (PDOException $e) {
405
            throw new RuntimeException('Database error', 0, $e);
406
        }
407
    }
408
409
    /**
410
     * Returns all version numbers for the given $contentId.
411
     *
412
     * @param mixed $contentId
413
     *
414
     * @return int[]
415
     */
416
    public function listVersionNumbers($contentId)
417
    {
418
        try {
419
            return $this->innerGateway->listVersionNumbers($contentId);
420
        } catch (DBALException $e) {
421
            throw new RuntimeException('Database error', 0, $e);
422
        } catch (PDOException $e) {
423
            throw new RuntimeException('Database error', 0, $e);
424
        }
425
    }
426
427
    /**
428
     * Returns last version number for content identified by $contentId.
429
     *
430
     * @param int $contentId
431
     *
432
     * @return int
433
     */
434
    public function getLastVersionNumber($contentId)
435
    {
436
        try {
437
            return $this->innerGateway->getLastVersionNumber($contentId);
438
        } catch (DBALException $e) {
439
            throw new RuntimeException('Database error', 0, $e);
440
        } catch (PDOException $e) {
441
            throw new RuntimeException('Database error', 0, $e);
442
        }
443
    }
444
445
    /**
446
     * Returns all IDs for locations that refer to $contentId.
447
     *
448
     * @param int $contentId
449
     *
450
     * @return int[]
451
     */
452
    public function getAllLocationIds($contentId)
453
    {
454
        try {
455
            return $this->innerGateway->getAllLocationIds($contentId);
456
        } catch (DBALException $e) {
457
            throw new RuntimeException('Database error', 0, $e);
458
        } catch (PDOException $e) {
459
            throw new RuntimeException('Database error', 0, $e);
460
        }
461
    }
462
463
    /**
464
     * Returns all field IDs of $contentId grouped by their type.
465
     * If $versionNo is set only field IDs for that version are returned.
466
     * If $languageCode is set, only field IDs for that language are returned.
467
     *
468
     * @param int $contentId
469
     * @param int|null $versionNo
470
     * @param string|null $languageCode
471
     *
472
     * @return int[][]
473
     */
474
    public function getFieldIdsByType($contentId, $versionNo = null, $languageCode = null)
475
    {
476
        try {
477
            return $this->innerGateway->getFieldIdsByType($contentId, $versionNo, $languageCode);
478
        } catch (DBALException $e) {
479
            throw new RuntimeException('Database error', 0, $e);
480
        } catch (PDOException $e) {
481
            throw new RuntimeException('Database error', 0, $e);
482
        }
483
    }
484
485
    /**
486
     * Deletes relations to and from $contentId.
487
     * If $versionNo is set only relations for that version are deleted.
488
     *
489
     * @param int $contentId
490
     * @param int|null $versionNo
491
     */
492
    public function deleteRelations($contentId, $versionNo = null)
493
    {
494
        try {
495
            return $this->innerGateway->deleteRelations($contentId, $versionNo);
496
        } catch (DBALException $e) {
497
            throw new RuntimeException('Database error', 0, $e);
498
        } catch (PDOException $e) {
499
            throw new RuntimeException('Database error', 0, $e);
500
        }
501
    }
502
503
    /**
504
     * Removes relations to Content with $contentId from Relation and RelationList field type fields.
505
     *
506
     * @param int $contentId
507
     */
508
    public function removeReverseFieldRelations($contentId)
509
    {
510
        try {
511
            return $this->innerGateway->removeReverseFieldRelations($contentId);
512
        } catch (DBALException $e) {
513
            throw new RuntimeException('Database error', 0, $e);
514
        } catch (PDOException $e) {
515
            throw new RuntimeException('Database error', 0, $e);
516
        }
517
    }
518
519
    /**
520
     * Deletes the field with the given $fieldId.
521
     *
522
     * @param int $fieldId
523
     */
524
    public function deleteField($fieldId)
525
    {
526
        try {
527
            return $this->innerGateway->deleteField($fieldId);
528
        } catch (DBALException $e) {
529
            throw new RuntimeException('Database error', 0, $e);
530
        } catch (PDOException $e) {
531
            throw new RuntimeException('Database error', 0, $e);
532
        }
533
    }
534
535
    /**
536
     * Deletes all fields of $contentId in all versions.
537
     * If $versionNo is set only fields for that version are deleted.
538
     *
539
     * @param int $contentId
540
     * @param int|null $versionNo
541
     */
542
    public function deleteFields($contentId, $versionNo = null)
543
    {
544
        try {
545
            return $this->innerGateway->deleteFields($contentId, $versionNo);
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
     * Deletes all versions of $contentId.
555
     * If $versionNo is set only that version is deleted.
556
     *
557
     * @param int $contentId
558
     * @param int|null $versionNo
559
     */
560
    public function deleteVersions($contentId, $versionNo = null)
561
    {
562
        try {
563
            return $this->innerGateway->deleteVersions($contentId, $versionNo);
564
        } catch (DBALException $e) {
565
            throw new RuntimeException('Database error', 0, $e);
566
        } catch (PDOException $e) {
567
            throw new RuntimeException('Database error', 0, $e);
568
        }
569
    }
570
571
    /**
572
     * Deletes all names of $contentId.
573
     * If $versionNo is set only names for that version are deleted.
574
     *
575
     * @param int $contentId
576
     * @param int|null $versionNo
577
     */
578
    public function deleteNames($contentId, $versionNo = null)
579
    {
580
        try {
581
            return $this->innerGateway->deleteNames($contentId, $versionNo);
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
     * Sets the content object name.
591
     *
592
     * @param int $contentId
593
     * @param int $version
594
     * @param string $name
595
     * @param string $language
596
     */
597
    public function setName($contentId, $version, $name, $language)
598
    {
599
        try {
600
            return $this->innerGateway->setName($contentId, $version, $name, $language);
601
        } catch (DBALException $e) {
602
            throw new RuntimeException('Database error', 0, $e);
603
        } catch (PDOException $e) {
604
            throw new RuntimeException('Database error', 0, $e);
605
        }
606
    }
607
608
    /**
609
     * Deletes the actual content object referred to by $contentId.
610
     *
611
     * @param int $contentId
612
     */
613
    public function deleteContent($contentId)
614
    {
615
        try {
616
            return $this->innerGateway->deleteContent($contentId);
617
        } catch (DBALException $e) {
618
            throw new RuntimeException('Database error', 0, $e);
619
        } catch (PDOException $e) {
620
            throw new RuntimeException('Database error', 0, $e);
621
        }
622
    }
623
624
    /**
625
     * Loads data of related to/from $contentId.
626
     *
627
     * @param int $contentId
628
     * @param int $contentVersionNo
629
     * @param int $relationType
630
     *
631
     * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}
632
     */
633
    public function loadRelations($contentId, $contentVersionNo = null, $relationType = null)
634
    {
635
        try {
636
            return $this->innerGateway->loadRelations($contentId, $contentVersionNo, $relationType);
637
        } catch (DBALException $e) {
638
            throw new RuntimeException('Database error', 0, $e);
639
        } catch (PDOException $e) {
640
            throw new RuntimeException('Database error', 0, $e);
641
        }
642
    }
643
644
    /**
645
     * Loads data of related to/from $contentId.
646
     *
647
     * @param int $contentId
648
     * @param bool $reverse Reverse relation, default false
0 ignored issues
show
Bug introduced by
There is no parameter named $reverse. Was it maybe removed?

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 method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
649
     * @param int $contentVersionNo
0 ignored issues
show
Bug introduced by
There is no parameter named $contentVersionNo. Was it maybe removed?

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 method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
650
     * @param int $relationType
651
     *
652
     * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}
653
     */
654
    public function loadReverseRelations($contentId, $relationType = null)
655
    {
656
        try {
657
            return $this->innerGateway->loadReverseRelations($contentId, $relationType);
658
        } catch (DBALException $e) {
659
            throw new RuntimeException('Database error', 0, $e);
660
        } catch (PDOException $e) {
661
            throw new RuntimeException('Database error', 0, $e);
662
        }
663
    }
664
665
    /**
666
     * Deletes the relation with the given $relationId.
667
     *
668
     * @param int $relationId
669
     * @param int $type {@see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON,
670
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::EMBED,
671
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::LINK,
672
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}
673
     */
674
    public function deleteRelation($relationId, $type)
675
    {
676
        try {
677
            return $this->innerGateway->deleteRelation($relationId, $type);
678
        } catch (DBALException $e) {
679
            throw new RuntimeException('Database error', 0, $e);
680
        } catch (PDOException $e) {
681
            throw new RuntimeException('Database error', 0, $e);
682
        }
683
    }
684
685
    /**
686
     * Inserts a new relation database record.
687
     *
688
     * @param \eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct $createStruct
0 ignored issues
show
Documentation introduced by
There is no parameter named $createStruct. Did you maybe mean $struct?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
689
     *
690
     * @return int ID the inserted ID
691
     */
692
    public function insertRelation(RelationCreateStruct $struct)
693
    {
694
        try {
695
            return $this->innerGateway->insertRelation($struct);
696
        } catch (DBALException $e) {
697
            throw new RuntimeException('Database error', 0, $e);
698
        } catch (PDOException $e) {
699
            throw new RuntimeException('Database error', 0, $e);
700
        }
701
    }
702
703
    /**
704
     * Returns all Content IDs for a given $contentTypeId.
705
     *
706
     * @param int $contentTypeId
707
     *
708
     * @return int[]
709
     */
710
    public function getContentIdsByContentTypeId($contentTypeId)
711
    {
712
        try {
713
            return $this->innerGateway->getContentIdsByContentTypeId($contentTypeId);
714
        } catch (DBALException $e) {
715
            throw new RuntimeException('Database error', 0, $e);
716
        } catch (PDOException $e) {
717
            throw new RuntimeException('Database error', 0, $e);
718
        }
719
    }
720
721
    /**
722
     * Load name data for set of content id's and corresponding version number.
723
     *
724
     * @param array[] $rows array of hashes with 'id' and 'version' to load names for
725
     *
726
     * @return array
727
     */
728
    public function loadVersionedNameData($rows)
729
    {
730
        try {
731
            return $this->innerGateway->loadVersionedNameData($rows);
732
        } catch (DBALException $e) {
733
            throw new RuntimeException('Database error', 0, $e);
734
        } catch (PDOException $e) {
735
            throw new RuntimeException('Database error', 0, $e);
736
        }
737
    }
738
739
    /**
740
     * Batch method for copying all relation meta data for copied Content object.
741
     *
742
     * {@inheritdoc}
743
     *
744
     * @param int $originalContentId
745
     * @param int $copiedContentId
746
     * @param int|null $versionNo If specified only copy for a given version number, otherwise all.
747
     */
748
    public function copyRelations($originalContentId, $copiedContentId, $versionNo = null)
749
    {
750
        try {
751
            return $this->innerGateway->copyRelations($originalContentId, $copiedContentId, $versionNo);
752
        } catch (DBALException $e) {
753
            throw new RuntimeException('Database error', 0, $e);
754
        } catch (PDOException $e) {
755
            throw new RuntimeException('Database error', 0, $e);
756
        }
757
    }
758
759
    /**
760
     * Remove the specified translation from all the Versions of a Content Object.
761
     *
762
     * @param int $contentId
763
     * @param string $languageCode language code of the translation
764
     */
765
    public function deleteTranslationFromContent($contentId, $languageCode)
766
    {
767
        try {
768
            return $this->innerGateway->deleteTranslationFromContent($contentId, $languageCode);
769
        } catch (DBALException $e) {
770
            throw new RuntimeException('Database error', 0, $e);
771
        } catch (PDOException $e) {
772
            throw new RuntimeException('Database error', 0, $e);
773
        }
774
    }
775
776
    /**
777
     * Delete Content fields (attributes) for the given Translation.
778
     * If $versionNo is given, fields for that Version only will be deleted.
779
     *
780
     * @param string $languageCode
781
     * @param int $contentId
782
     * @param int $versionNo (optional) filter by versionNo
783
     */
784
    public function deleteTranslatedFields($languageCode, $contentId, $versionNo = null)
785
    {
786
        try {
787
            return $this->innerGateway->deleteTranslatedFields($languageCode, $contentId, $versionNo);
788
        } catch (DBALException $e) {
789
            throw new RuntimeException('Database error', 0, $e);
790
        } catch (PDOException $e) {
791
            throw new RuntimeException('Database error', 0, $e);
792
        }
793
    }
794
795
    /**
796
     * Delete the specified Translation from the given Version.
797
     *
798
     * @param int $contentId
799
     * @param int $versionNo
800
     * @param string $languageCode
801
     */
802
    public function deleteTranslationFromVersion($contentId, $versionNo, $languageCode)
803
    {
804
        try {
805
            return $this->innerGateway->deleteTranslationFromVersion($contentId, $versionNo, $languageCode);
806
        } catch (DBALException $e) {
807
            throw new RuntimeException('Database error', 0, $e);
808
        } catch (PDOException $e) {
809
            throw new RuntimeException('Database error', 0, $e);
810
        }
811
    }
812
}
813