Completed
Push — 7.5 ( 22ec60...932e58 )
by André
23:01
created

ExceptionConversion::getFallbackMainNodeData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the Location Gateway class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway;
10
11
use eZ\Publish\Core\Base\Exceptions\DatabaseException;
12
use eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway;
13
use eZ\Publish\SPI\Persistence\Content\Location\UpdateStruct;
14
use eZ\Publish\SPI\Persistence\Content\Location\CreateStruct;
15
use Doctrine\DBAL\DBALException;
16
use PDOException;
17
18
/**
19
 * Base class for location gateways.
20
 */
21
class ExceptionConversion extends Gateway
22
{
23
    /**
24
     * The wrapped gateway.
25
     *
26
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway
27
     */
28
    protected $innerGateway;
29
30
    /**
31
     * Creates a new exception conversion gateway around $innerGateway.
32
     *
33
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway $innerGateway
34
     */
35
    public function __construct(Gateway $innerGateway)
36
    {
37
        $this->innerGateway = $innerGateway;
38
    }
39
40
    public function getBasicNodeData($nodeId, array $translations = null, bool $useAlwaysAvailable = true)
41
    {
42
        try {
43
            return $this->innerGateway->getBasicNodeData($nodeId, $translations, $useAlwaysAvailable);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 40 can also be of type array; however, eZ\Publish\Core\Persiste...way::getBasicNodeData() 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...
44
        } catch (DBALException | PDOException $e) {
45
            throw DatabaseException::wrap($e);
46
        }
47
    }
48
49
    public function getNodeDataList(array $locationIds, array $translations = null, bool $useAlwaysAvailable = true): iterable
50
    {
51
        try {
52
            return $this->innerGateway->getNodeDataList($locationIds, $translations, $useAlwaysAvailable);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 49 can also be of type array; however, eZ\Publish\Core\Persiste...eway::getNodeDataList() 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...
53
        } catch (DBALException | PDOException $e) {
54
            throw DatabaseException::wrap($e);
55
        }
56
    }
57
58
    public function getBasicNodeDataByRemoteId($remoteId, array $translations = null, bool $useAlwaysAvailable = true)
59
    {
60
        try {
61
            return $this->innerGateway->getBasicNodeDataByRemoteId($remoteId, $translations, $useAlwaysAvailable);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 58 can also be of type array; however, eZ\Publish\Core\Persiste...sicNodeDataByRemoteId() 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...
62
        } catch (DBALException | PDOException $e) {
63
            throw DatabaseException::wrap($e);
64
        }
65
    }
66
67
    public function loadLocationDataByContent($contentId, $rootLocationId = null)
68
    {
69
        try {
70
            return $this->innerGateway->loadLocationDataByContent($contentId, $rootLocationId);
71
        } catch (DBALException | PDOException $e) {
72
            throw DatabaseException::wrap($e);
73
        }
74
    }
75
76
    public function loadParentLocationsDataForDraftContent($contentId)
77
    {
78
        try {
79
            return $this->innerGateway->loadParentLocationsDataForDraftContent($contentId);
80
        } catch (DBALException | PDOException $e) {
81
            throw DatabaseException::wrap($e);
82
        }
83
    }
84
85
    public function getSubtreeContent($sourceId, $onlyIds = false)
86
    {
87
        try {
88
            return $this->innerGateway->getSubtreeContent($sourceId, $onlyIds);
89
        } catch (DBALException | PDOException $e) {
90
            throw DatabaseException::wrap($e);
91
        }
92
    }
93
94
    public function getChildren($locationId)
95
    {
96
        try {
97
            return $this->innerGateway->getChildren($locationId);
98
        } catch (DBALException | PDOException $e) {
99
            throw DatabaseException::wrap($e);
100
        }
101
    }
102
103
    public function moveSubtreeNodes(array $fromPathString, array $toPathString)
104
    {
105
        try {
106
            return $this->innerGateway->moveSubtreeNodes($fromPathString, $toPathString);
107
        } catch (DBALException | PDOException $e) {
108
            throw DatabaseException::wrap($e);
109
        }
110
    }
111
112
    public function updateSubtreeModificationTime($pathString, $timestamp = null)
113
    {
114
        try {
115
            return $this->innerGateway->updateSubtreeModificationTime($pathString, $timestamp);
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Persiste...btreeModificationTime() has been deprecated with message: Not supposed to be in use anymore.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
116
        } catch (DBALException | PDOException $e) {
117
            throw DatabaseException::wrap($e);
118
        }
119
    }
120
121
    public function updateNodeAssignment($contentObjectId, $oldParent, $newParent, $opcode)
122
    {
123
        try {
124
            return $this->innerGateway->updateNodeAssignment($contentObjectId, $oldParent, $newParent, $opcode);
125
        } catch (DBALException | PDOException $e) {
126
            throw DatabaseException::wrap($e);
127
        }
128
    }
129
130
    public function createLocationsFromNodeAssignments($contentId, $versionNo)
131
    {
132
        try {
133
            return $this->innerGateway->createLocationsFromNodeAssignments($contentId, $versionNo);
134
        } catch (DBALException | PDOException $e) {
135
            throw DatabaseException::wrap($e);
136
        }
137
    }
138
139
    public function updateLocationsContentVersionNo($contentId, $versionNo)
140
    {
141
        try {
142
            return $this->innerGateway->updateLocationsContentVersionNo($contentId, $versionNo);
143
        } catch (DBALException | PDOException $e) {
144
            throw DatabaseException::wrap($e);
145
        }
146
    }
147
148
    public function hideSubtree($pathString)
149
    {
150
        try {
151
            return $this->innerGateway->hideSubtree($pathString);
152
        } catch (DBALException | PDOException $e) {
153
            throw DatabaseException::wrap($e);
154
        }
155
    }
156
157
    public function unHideSubtree($pathString)
158
    {
159
        try {
160
            return $this->innerGateway->unHideSubtree($pathString);
161
        } catch (DBALException | PDOException $e) {
162
            throw DatabaseException::wrap($e);
163
        }
164
    }
165
166
    public function setNodeWithChildrenInvisible(string $pathString): void
167
    {
168
        try {
169
            $this->innerGateway->setNodeWithChildrenInvisible($pathString);
170
        } catch (DBALException | PDOException $e) {
171
            throw DatabaseException::wrap($e);
172
        }
173
    }
174
175
    public function setNodeHidden(string $pathString): void
176
    {
177
        try {
178
            $this->innerGateway->setNodeHidden($pathString);
179
        } catch (DBALException | PDOException $e) {
180
            throw DatabaseException::wrap($e);
181
        }
182
    }
183
184
    public function setNodeWithChildrenVisible(string $pathString): void
185
    {
186
        try {
187
            $this->innerGateway->setNodeWithChildrenVisible($pathString);
188
        } catch (DBALException | PDOException $e) {
189
            throw DatabaseException::wrap($e);
190
        }
191
    }
192
193
    public function setNodeUnhidden(string $pathString): void
194
    {
195
        try {
196
            $this->innerGateway->setNodeUnhidden($pathString);
197
        } catch (DBALException | PDOException $e) {
198
            throw DatabaseException::wrap($e);
199
        }
200
    }
201
202
    public function swap(int $locationId1, int $locationId2): bool
203
    {
204
        try {
205
            return $this->innerGateway->swap($locationId1, $locationId2);
206
        } catch (DBALException | PDOException $e) {
207
            throw DatabaseException::wrap($e);
208
        }
209
    }
210
211
    public function create(CreateStruct $createStruct, array $parentNode)
212
    {
213
        try {
214
            return $this->innerGateway->create($createStruct, $parentNode);
215
        } catch (DBALException | PDOException $e) {
216
            throw DatabaseException::wrap($e);
217
        }
218
    }
219
220
    public function createNodeAssignment(CreateStruct $createStruct, $parentNodeId, $type = self::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP)
221
    {
222
        try {
223
            return $this->innerGateway->createNodeAssignment($createStruct, $parentNodeId, $type);
224
        } catch (DBALException | PDOException $e) {
225
            throw DatabaseException::wrap($e);
226
        }
227
    }
228
229
    public function deleteNodeAssignment($contentId, $versionNo = null)
230
    {
231
        try {
232
            return $this->innerGateway->deleteNodeAssignment($contentId, $versionNo);
233
        } catch (DBALException | PDOException $e) {
234
            throw DatabaseException::wrap($e);
235
        }
236
    }
237
238
    public function update(UpdateStruct $location, $locationId)
239
    {
240
        try {
241
            return $this->innerGateway->update($location, $locationId);
242
        } catch (DBALException | PDOException $e) {
243
            throw DatabaseException::wrap($e);
244
        }
245
    }
246
247
    public function updatePathIdentificationString($locationId, $parentLocationId, $text)
248
    {
249
        try {
250
            return $this->innerGateway->updatePathIdentificationString($locationId, $parentLocationId, $text);
251
        } catch (DBALException | PDOException $e) {
252
            throw DatabaseException::wrap($e);
253
        }
254
    }
255
256
    public function removeLocation($locationId)
257
    {
258
        try {
259
            return $this->innerGateway->removeLocation($locationId);
260
        } catch (DBALException | PDOException $e) {
261
            throw DatabaseException::wrap($e);
262
        }
263
    }
264
265
    public function getFallbackMainNodeData($contentId, $locationId)
266
    {
267
        try {
268
            return $this->innerGateway->getFallbackMainNodeData($contentId, $locationId);
269
        } catch (DBALException | PDOException $e) {
270
            throw DatabaseException::wrap($e);
271
        }
272
    }
273
274
    public function trashLocation($locationId)
275
    {
276
        try {
277
            return $this->innerGateway->trashLocation($locationId);
278
        } catch (DBALException | PDOException $e) {
279
            throw DatabaseException::wrap($e);
280
        }
281
    }
282
283
    public function untrashLocation($locationId, $newParentId = null)
284
    {
285
        try {
286
            return $this->innerGateway->untrashLocation($locationId, $newParentId);
287
        } catch (DBALException | PDOException $e) {
288
            throw DatabaseException::wrap($e);
289
        }
290
    }
291
292
    public function loadTrashByLocation($locationId)
293
    {
294
        try {
295
            return $this->innerGateway->loadTrashByLocation($locationId);
296
        } catch (DBALException | PDOException $e) {
297
            throw DatabaseException::wrap($e);
298
        }
299
    }
300
301
    public function cleanupTrash()
302
    {
303
        try {
304
            return $this->innerGateway->cleanupTrash();
305
        } catch (DBALException | PDOException $e) {
306
            throw DatabaseException::wrap($e);
307
        }
308
    }
309
310
    public function listTrashed($offset, $limit, array $sort = null)
311
    {
312
        try {
313
            return $this->innerGateway->listTrashed($offset, $limit, $sort);
314
        } catch (DBALException | PDOException $e) {
315
            throw DatabaseException::wrap($e);
316
        }
317
    }
318
319
    public function countTrashed(): int
320
    {
321
        try {
322
            return $this->innerGateway->countTrashed();
323
        } catch (DBALException | PDOException $e) {
324
            throw DatabaseException::wrap($e);
325
        }
326
    }
327
328
    public function removeElementFromTrash($id)
329
    {
330
        try {
331
            return $this->innerGateway->removeElementFromTrash($id);
332
        } catch (DBALException | PDOException $e) {
333
            throw DatabaseException::wrap($e);
334
        }
335
    }
336
337
    public function setSectionForSubtree($pathString, $sectionId)
338
    {
339
        try {
340
            return $this->innerGateway->setSectionForSubtree($pathString, $sectionId);
341
        } catch (DBALException | PDOException $e) {
342
            throw DatabaseException::wrap($e);
343
        }
344
    }
345
346
    public function countLocationsByContentId($contentId)
347
    {
348
        try {
349
            return $this->innerGateway->countLocationsByContentId($contentId);
350
        } catch (DBALException | PDOException $e) {
351
            throw DatabaseException::wrap($e);
352
        }
353
    }
354
355
    public function changeMainLocation($contentId, $locationId, $versionNo, $parentLocationId)
356
    {
357
        try {
358
            return $this->innerGateway->changeMainLocation($contentId, $locationId, $versionNo, $parentLocationId);
359
        } catch (DBALException | PDOException $e) {
360
            throw DatabaseException::wrap($e);
361
        }
362
    }
363
364
    public function countAllLocations()
365
    {
366
        try {
367
            return $this->innerGateway->countAllLocations();
368
        } catch (DBALException | PDOException $e) {
369
            throw DatabaseException::wrap($e);
370
        }
371
    }
372
373
    public function loadAllLocationsData($offset, $limit)
374
    {
375
        try {
376
            return $this->innerGateway->loadAllLocationsData($offset, $limit);
377
        } catch (DBALException | PDOException $e) {
378
            throw DatabaseException::wrap($e);
379
        }
380
    }
381
}
382