Completed
Push — master ( 2dca3b...5a27f3 )
by
unknown
16:48 queued 02:47
created

ExceptionConversion::countVersionsForUser()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
cc 2
nc 2
nop 2
rs 10
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
     * {@inheritdoc}
259
     */
260
    public function load($contentId, $version = null, array $translations = null)
261
    {
262
        try {
263
            return $this->innerGateway->load($contentId, $version, $translations);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 260 can also be of type array; however, eZ\Publish\Core\Persiste...Content\Gateway::load() does only seem to accept null|array<integer,string>, maybe add an additional type check?

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.

Loading history...
264
        } catch (DBALException $e) {
265
            throw new RuntimeException('Database error', 0, $e);
266
        } catch (PDOException $e) {
267
            throw new RuntimeException('Database error', 0, $e);
268
        }
269
    }
270
271
    /**
272
     * {@inheritdoc}
273
     */
274
    public function loadContentList(array $contentIds, array $translations = null): array
275
    {
276
        try {
277
            return $this->innerGateway->loadContentList($contentIds, $translations);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 274 can also be of type array; however, eZ\Publish\Core\Persiste...eway::loadContentList() does only seem to accept null|array<integer,string>, maybe add an additional type check?

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.

Loading history...
278
        } catch (DBALException | PDOException $e) {
279
            throw new RuntimeException('Database error', 0, $e);
280
        }
281
    }
282
283
    /**
284
     * Loads data for a content object identified by its remote ID.
285
     *
286
     * Returns an array with the relevant data.
287
     *
288
     * @param mixed $remoteId
289
     *
290
     * @return array
291
     */
292
    public function loadContentInfoByRemoteId($remoteId)
293
    {
294
        try {
295
            return $this->innerGateway->loadContentInfoByRemoteId($remoteId);
296
        } catch (DBALException $e) {
297
            throw new \RuntimeException('Database error', 0, $e);
298
        } catch (\PDOException $e) {
299
            throw new \RuntimeException('Database error', 0, $e);
300
        }
301
    }
302
303
    /**
304
     * Loads info for a content object identified by its location ID (node ID).
305
     *
306
     * Returns an array with the relevant data.
307
     *
308
     * @param int $locationId
309
     *
310
     * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException
311
     *
312
     * @return array
313
     */
314
    public function loadContentInfoByLocationId($locationId)
315
    {
316
        try {
317
            return $this->innerGateway->loadContentInfoByLocationId($locationId);
318
        } catch (DBALException $e) {
319
            throw new \RuntimeException('Database error', 0, $e);
320
        } catch (\PDOException $e) {
321
            throw new \RuntimeException('Database error', 0, $e);
322
        }
323
    }
324
325
    /**
326
     * Loads info for content identified by $contentId.
327
     * Will basically return a hash containing all field values for ezcontentobject table plus following keys:
328
     *  - always_available => Boolean indicating if content's language mask contains alwaysAvailable bit field
329
     *  - main_language_code => Language code for main (initial) language. E.g. "eng-GB".
330
     *
331
     * @param int $contentId
332
     *
333
     * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException
334
     *
335
     * @return array
336
     */
337
    public function loadContentInfo($contentId)
338
    {
339
        try {
340
            return $this->innerGateway->loadContentInfo($contentId);
341
        } catch (DBALException $e) {
342
            throw new RuntimeException('Database error', 0, $e);
343
        } catch (PDOException $e) {
344
            throw new RuntimeException('Database error', 0, $e);
345
        }
346
    }
347
348
    public function loadContentInfoList(array $contentIds)
349
    {
350
        try {
351
            return $this->innerGateway->loadContentInfoList($contentIds);
352
        } catch (DBALException $e) {
353
            throw new RuntimeException('Database error', 0, $e);
354
        } catch (PDOException $e) {
355
            throw new RuntimeException('Database error', 0, $e);
356
        }
357
    }
358
359
    /**
360
     * Loads version info for content identified by $contentId and $versionNo.
361
     * Will basically return a hash containing all field values from ezcontentobject_version table plus following keys:
362
     *  - names => Hash of content object names. Key is the language code, value is the name.
363
     *  - 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.
364
     *  - initial_language_code => Language code for initial language in this version.
365
     *
366
     * @param int $contentId
367
     * @param int|null $versionNo
368
     *
369
     * @return array
370
     */
371
    public function loadVersionInfo($contentId, $versionNo = null)
372
    {
373
        try {
374
            return $this->innerGateway->loadVersionInfo($contentId, $versionNo);
375
        } catch (DBALException $e) {
376
            throw new RuntimeException('Database error', 0, $e);
377
        } catch (PDOException $e) {
378
            throw new RuntimeException('Database error', 0, $e);
379
        }
380
    }
381
382
    /**
383
     * Returns the number of all versions with given status created by the given $userId.
384
     *
385
     * @param int $userId
386
     * @param int $status
387
     *
388
     * @return int
389
     */
390
    public function countVersionsForUser(int $userId, int $status = VersionInfo::STATUS_DRAFT): int
391
    {
392
        try {
393
            return $this->innerGateway->countVersionsForUser($userId, $status);
394
        } catch (DBALException | PDOException $e) {
395
            throw new RuntimeException('Database error', 0, $e);
396
        }
397
    }
398
399
    /**
400
     * Returns data for all versions with given status created by the given $userId.
401
     *
402
     * @param int $userId
403
     * @param int $status
404
     *
405
     * @return string[][]
406
     */
407
    public function listVersionsForUser($userId, $status = VersionInfo::STATUS_DRAFT, int $offset = 0, int $limit = -1)
408
    {
409
        try {
410
            return $this->innerGateway->listVersionsForUser($userId, $status, $offset, $limit);
411
        } catch (DBALException $e) {
412
            throw new RuntimeException('Database error', 0, $e);
413
        } catch (PDOException $e) {
414
            throw new RuntimeException('Database error', 0, $e);
415
        }
416
    }
417
418
    /**
419
     * {@inheritdoc}
420
     */
421
    public function loadVersionsForUser($userId, $status = VersionInfo::STATUS_DRAFT, int $offset = 0, int $limit = -1): array
422
    {
423
        try {
424
            return $this->innerGateway->loadVersionsForUser($userId, $status, $offset, $limit);
425
        } catch (DBALException | PDOException $e) {
426
            throw new RuntimeException('Database error', 0, $e);
427
        }
428
    }
429
430
    /**
431
     * Returns all version data for the given $contentId.
432
     *
433
     * Result is returned with oldest version first (using version id as it has index and is auto increment).
434
     *
435
     * @param mixed $contentId
436
     * @param mixed|null $status Optional argument to filter versions by status, like {@see VersionInfo::STATUS_ARCHIVED}.
437
     * @param int $limit Limit for items returned, -1 means none.
438
     *
439
     * @return string[][]
440
     */
441
    public function listVersions($contentId, $status = null, $limit = -1)
442
    {
443
        try {
444
            return $this->innerGateway->listVersions($contentId, $status, $limit);
445
        } catch (DBALException $e) {
446
            throw new RuntimeException('Database error', 0, $e);
447
        } catch (PDOException $e) {
448
            throw new RuntimeException('Database error', 0, $e);
449
        }
450
    }
451
452
    /**
453
     * Returns all version numbers for the given $contentId.
454
     *
455
     * @param mixed $contentId
456
     *
457
     * @return int[]
458
     */
459
    public function listVersionNumbers($contentId)
460
    {
461
        try {
462
            return $this->innerGateway->listVersionNumbers($contentId);
463
        } catch (DBALException $e) {
464
            throw new RuntimeException('Database error', 0, $e);
465
        } catch (PDOException $e) {
466
            throw new RuntimeException('Database error', 0, $e);
467
        }
468
    }
469
470
    /**
471
     * Returns last version number for content identified by $contentId.
472
     *
473
     * @param int $contentId
474
     *
475
     * @return int
476
     */
477
    public function getLastVersionNumber($contentId)
478
    {
479
        try {
480
            return $this->innerGateway->getLastVersionNumber($contentId);
481
        } catch (DBALException $e) {
482
            throw new RuntimeException('Database error', 0, $e);
483
        } catch (PDOException $e) {
484
            throw new RuntimeException('Database error', 0, $e);
485
        }
486
    }
487
488
    /**
489
     * Returns all IDs for locations that refer to $contentId.
490
     *
491
     * @param int $contentId
492
     *
493
     * @return int[]
494
     */
495
    public function getAllLocationIds($contentId)
496
    {
497
        try {
498
            return $this->innerGateway->getAllLocationIds($contentId);
499
        } catch (DBALException $e) {
500
            throw new RuntimeException('Database error', 0, $e);
501
        } catch (PDOException $e) {
502
            throw new RuntimeException('Database error', 0, $e);
503
        }
504
    }
505
506
    /**
507
     * Returns all field IDs of $contentId grouped by their type.
508
     * If $versionNo is set only field IDs for that version are returned.
509
     * If $languageCode is set, only field IDs for that language are returned.
510
     *
511
     * @param int $contentId
512
     * @param int|null $versionNo
513
     * @param string|null $languageCode
514
     *
515
     * @return int[][]
516
     */
517
    public function getFieldIdsByType($contentId, $versionNo = null, $languageCode = null)
518
    {
519
        try {
520
            return $this->innerGateway->getFieldIdsByType($contentId, $versionNo, $languageCode);
521
        } catch (DBALException $e) {
522
            throw new RuntimeException('Database error', 0, $e);
523
        } catch (PDOException $e) {
524
            throw new RuntimeException('Database error', 0, $e);
525
        }
526
    }
527
528
    /**
529
     * Deletes relations to and from $contentId.
530
     * If $versionNo is set only relations for that version are deleted.
531
     *
532
     * @param int $contentId
533
     * @param int|null $versionNo
534
     */
535
    public function deleteRelations($contentId, $versionNo = null)
536
    {
537
        try {
538
            return $this->innerGateway->deleteRelations($contentId, $versionNo);
539
        } catch (DBALException $e) {
540
            throw new RuntimeException('Database error', 0, $e);
541
        } catch (PDOException $e) {
542
            throw new RuntimeException('Database error', 0, $e);
543
        }
544
    }
545
546
    /**
547
     * Removes relations to Content with $contentId from Relation and RelationList field type fields.
548
     *
549
     * @param int $contentId
550
     */
551
    public function removeReverseFieldRelations($contentId)
552
    {
553
        try {
554
            return $this->innerGateway->removeReverseFieldRelations($contentId);
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
     * Deletes the field with the given $fieldId.
564
     *
565
     * @param int $fieldId
566
     */
567
    public function deleteField($fieldId)
568
    {
569
        try {
570
            return $this->innerGateway->deleteField($fieldId);
571
        } catch (DBALException $e) {
572
            throw new RuntimeException('Database error', 0, $e);
573
        } catch (PDOException $e) {
574
            throw new RuntimeException('Database error', 0, $e);
575
        }
576
    }
577
578
    /**
579
     * Deletes all fields of $contentId in all versions.
580
     * If $versionNo is set only fields for that version are deleted.
581
     *
582
     * @param int $contentId
583
     * @param int|null $versionNo
584
     */
585
    public function deleteFields($contentId, $versionNo = null)
586
    {
587
        try {
588
            return $this->innerGateway->deleteFields($contentId, $versionNo);
589
        } catch (DBALException $e) {
590
            throw new RuntimeException('Database error', 0, $e);
591
        } catch (PDOException $e) {
592
            throw new RuntimeException('Database error', 0, $e);
593
        }
594
    }
595
596
    /**
597
     * Deletes all versions of $contentId.
598
     * If $versionNo is set only that version is deleted.
599
     *
600
     * @param int $contentId
601
     * @param int|null $versionNo
602
     */
603
    public function deleteVersions($contentId, $versionNo = null)
604
    {
605
        try {
606
            return $this->innerGateway->deleteVersions($contentId, $versionNo);
607
        } catch (DBALException $e) {
608
            throw new RuntimeException('Database error', 0, $e);
609
        } catch (PDOException $e) {
610
            throw new RuntimeException('Database error', 0, $e);
611
        }
612
    }
613
614
    /**
615
     * Deletes all names of $contentId.
616
     * If $versionNo is set only names for that version are deleted.
617
     *
618
     * @param int $contentId
619
     * @param int|null $versionNo
620
     */
621
    public function deleteNames($contentId, $versionNo = null)
622
    {
623
        try {
624
            return $this->innerGateway->deleteNames($contentId, $versionNo);
625
        } catch (DBALException $e) {
626
            throw new RuntimeException('Database error', 0, $e);
627
        } catch (PDOException $e) {
628
            throw new RuntimeException('Database error', 0, $e);
629
        }
630
    }
631
632
    /**
633
     * Sets the content object name.
634
     *
635
     * @param int $contentId
636
     * @param int $version
637
     * @param string $name
638
     * @param string $language
639
     */
640
    public function setName($contentId, $version, $name, $language)
641
    {
642
        try {
643
            return $this->innerGateway->setName($contentId, $version, $name, $language);
644
        } catch (DBALException $e) {
645
            throw new RuntimeException('Database error', 0, $e);
646
        } catch (PDOException $e) {
647
            throw new RuntimeException('Database error', 0, $e);
648
        }
649
    }
650
651
    /**
652
     * Deletes the actual content object referred to by $contentId.
653
     *
654
     * @param int $contentId
655
     */
656
    public function deleteContent($contentId)
657
    {
658
        try {
659
            return $this->innerGateway->deleteContent($contentId);
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
    /**
668
     * Loads data of related to/from $contentId.
669
     *
670
     * @param int $contentId
671
     * @param int $contentVersionNo
672
     * @param int $relationType
673
     *
674
     * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}
675
     */
676
    public function loadRelations($contentId, $contentVersionNo = null, $relationType = null)
677
    {
678
        try {
679
            return $this->innerGateway->loadRelations($contentId, $contentVersionNo, $relationType);
680
        } catch (DBALException $e) {
681
            throw new RuntimeException('Database error', 0, $e);
682
        } catch (PDOException $e) {
683
            throw new RuntimeException('Database error', 0, $e);
684
        }
685
    }
686
687
    /**
688
     * Loads data of related to/from $contentId.
689
     *
690
     * @param int $contentId
691
     * @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...
692
     * @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...
693
     * @param int $relationType
694
     *
695
     * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}
696
     */
697
    public function loadReverseRelations($contentId, $relationType = null)
698
    {
699
        try {
700
            return $this->innerGateway->loadReverseRelations($contentId, $relationType);
701
        } catch (DBALException $e) {
702
            throw new RuntimeException('Database error', 0, $e);
703
        } catch (PDOException $e) {
704
            throw new RuntimeException('Database error', 0, $e);
705
        }
706
    }
707
708
    /**
709
     * Deletes the relation with the given $relationId.
710
     *
711
     * @param int $relationId
712
     * @param int $type {@see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON,
713
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::EMBED,
714
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::LINK,
715
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}
716
     */
717
    public function deleteRelation($relationId, $type)
718
    {
719
        try {
720
            return $this->innerGateway->deleteRelation($relationId, $type);
721
        } catch (DBALException $e) {
722
            throw new RuntimeException('Database error', 0, $e);
723
        } catch (PDOException $e) {
724
            throw new RuntimeException('Database error', 0, $e);
725
        }
726
    }
727
728
    /**
729
     * Inserts a new relation database record.
730
     *
731
     * @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...
732
     *
733
     * @return int ID the inserted ID
734
     */
735
    public function insertRelation(RelationCreateStruct $struct)
736
    {
737
        try {
738
            return $this->innerGateway->insertRelation($struct);
739
        } catch (DBALException $e) {
740
            throw new RuntimeException('Database error', 0, $e);
741
        } catch (PDOException $e) {
742
            throw new RuntimeException('Database error', 0, $e);
743
        }
744
    }
745
746
    /**
747
     * Returns all Content IDs for a given $contentTypeId.
748
     *
749
     * @param int $contentTypeId
750
     *
751
     * @return int[]
752
     */
753
    public function getContentIdsByContentTypeId($contentTypeId)
754
    {
755
        try {
756
            return $this->innerGateway->getContentIdsByContentTypeId($contentTypeId);
757
        } catch (DBALException $e) {
758
            throw new RuntimeException('Database error', 0, $e);
759
        } catch (PDOException $e) {
760
            throw new RuntimeException('Database error', 0, $e);
761
        }
762
    }
763
764
    /**
765
     * Load name data for set of content id's and corresponding version number.
766
     *
767
     * @param array[] $rows array of hashes with 'id' and 'version' to load names for
768
     *
769
     * @return array
770
     */
771
    public function loadVersionedNameData($rows)
772
    {
773
        try {
774
            return $this->innerGateway->loadVersionedNameData($rows);
775
        } catch (DBALException $e) {
776
            throw new RuntimeException('Database error', 0, $e);
777
        } catch (PDOException $e) {
778
            throw new RuntimeException('Database error', 0, $e);
779
        }
780
    }
781
782
    /**
783
     * Batch method for copying all relation meta data for copied Content object.
784
     *
785
     * {@inheritdoc}
786
     *
787
     * @param int $originalContentId
788
     * @param int $copiedContentId
789
     * @param int|null $versionNo If specified only copy for a given version number, otherwise all.
790
     */
791
    public function copyRelations($originalContentId, $copiedContentId, $versionNo = null)
792
    {
793
        try {
794
            return $this->innerGateway->copyRelations($originalContentId, $copiedContentId, $versionNo);
795
        } catch (DBALException $e) {
796
            throw new RuntimeException('Database error', 0, $e);
797
        } catch (PDOException $e) {
798
            throw new RuntimeException('Database error', 0, $e);
799
        }
800
    }
801
802
    /**
803
     * Remove the specified translation from all the Versions of a Content Object.
804
     *
805
     * @param int $contentId
806
     * @param string $languageCode language code of the translation
807
     */
808
    public function deleteTranslationFromContent($contentId, $languageCode)
809
    {
810
        try {
811
            return $this->innerGateway->deleteTranslationFromContent($contentId, $languageCode);
812
        } catch (DBALException $e) {
813
            throw new RuntimeException('Database error', 0, $e);
814
        } catch (PDOException $e) {
815
            throw new RuntimeException('Database error', 0, $e);
816
        }
817
    }
818
819
    /**
820
     * Delete Content fields (attributes) for the given Translation.
821
     * If $versionNo is given, fields for that Version only will be deleted.
822
     *
823
     * @param string $languageCode
824
     * @param int $contentId
825
     * @param int $versionNo (optional) filter by versionNo
826
     */
827
    public function deleteTranslatedFields($languageCode, $contentId, $versionNo = null)
828
    {
829
        try {
830
            return $this->innerGateway->deleteTranslatedFields($languageCode, $contentId, $versionNo);
831
        } catch (DBALException $e) {
832
            throw new RuntimeException('Database error', 0, $e);
833
        } catch (PDOException $e) {
834
            throw new RuntimeException('Database error', 0, $e);
835
        }
836
    }
837
838
    /**
839
     * Delete the specified Translation from the given Version.
840
     *
841
     * @param int $contentId
842
     * @param int $versionNo
843
     * @param string $languageCode
844
     */
845
    public function deleteTranslationFromVersion($contentId, $versionNo, $languageCode)
846
    {
847
        try {
848
            return $this->innerGateway->deleteTranslationFromVersion($contentId, $versionNo, $languageCode);
849
        } catch (DBALException $e) {
850
            throw new RuntimeException('Database error', 0, $e);
851
        } catch (PDOException $e) {
852
            throw new RuntimeException('Database error', 0, $e);
853
        }
854
    }
855
}
856