Completed
Push — 6.7 ( 0b0687...bec934 )
by Łukasz
20:09
created

ExceptionConversion::loadContentInfoByLocationId()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Importance

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