Completed
Push — EZEE-3159 ( 9c86bd )
by
unknown
19:29
created

loadLocationDataByTrashContent()   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
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway;
8
9
use eZ\Publish\Core\Base\Exceptions\DatabaseException;
10
use eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway;
11
use eZ\Publish\SPI\Persistence\Content\Location\UpdateStruct;
12
use eZ\Publish\SPI\Persistence\Content\Location\CreateStruct;
13
use Doctrine\DBAL\DBALException;
14
use PDOException;
15
16
/**
17
 * Base class for location gateways.
18
 */
19
class ExceptionConversion extends Gateway
20
{
21
    /**
22
     * The wrapped gateway.
23
     *
24
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway
25
     */
26
    protected $innerGateway;
27
28
    /**
29
     * Creates a new exception conversion gateway around $innerGateway.
30
     *
31
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway $innerGateway
32
     */
33
    public function __construct(Gateway $innerGateway)
34
    {
35
        $this->innerGateway = $innerGateway;
36
    }
37
38
    public function getBasicNodeData($nodeId, array $translations = null, bool $useAlwaysAvailable = true)
39
    {
40
        try {
41
            return $this->innerGateway->getBasicNodeData($nodeId, $translations, $useAlwaysAvailable);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 38 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...
42
        } catch (DBALException | PDOException $e) {
43
            throw DatabaseException::wrap($e);
44
        }
45
    }
46
47
    public function getNodeDataList(array $locationIds, array $translations = null, bool $useAlwaysAvailable = true): iterable
48
    {
49
        try {
50
            return $this->innerGateway->getNodeDataList($locationIds, $translations, $useAlwaysAvailable);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 47 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...
51
        } catch (DBALException | PDOException $e) {
52
            throw DatabaseException::wrap($e);
53
        }
54
    }
55
56
    public function getBasicNodeDataByRemoteId($remoteId, array $translations = null, bool $useAlwaysAvailable = true)
57
    {
58
        try {
59
            return $this->innerGateway->getBasicNodeDataByRemoteId($remoteId, $translations, $useAlwaysAvailable);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 56 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...
60
        } catch (DBALException | PDOException $e) {
61
            throw DatabaseException::wrap($e);
62
        }
63
    }
64
65
    public function loadLocationDataByContent($contentId, $rootLocationId = null)
66
    {
67
        try {
68
            return $this->innerGateway->loadLocationDataByContent($contentId, $rootLocationId);
69
        } catch (DBALException | PDOException $e) {
70
            throw DatabaseException::wrap($e);
71
        }
72
    }
73
74
    public function loadLocationDataByTrashContent($contentId, $rootLocationId = null)
75
    {
76
        try {
77
            return $this->innerGateway->loadLocationDataByTrashContent($contentId, $rootLocationId);
78
        } catch (DBALException | PDOException $e) {
79
            throw DatabaseException::wrap($e);
80
        }
81
    }
82
83
    public function loadParentLocationsDataForDraftContent($contentId)
84
    {
85
        try {
86
            return $this->innerGateway->loadParentLocationsDataForDraftContent($contentId);
87
        } catch (DBALException | PDOException $e) {
88
            throw DatabaseException::wrap($e);
89
        }
90
    }
91
92
    public function getSubtreeContent($sourceId, $onlyIds = false)
93
    {
94
        try {
95
            return $this->innerGateway->getSubtreeContent($sourceId, $onlyIds);
96
        } catch (DBALException | PDOException $e) {
97
            throw DatabaseException::wrap($e);
98
        }
99
    }
100
101
    public function getChildren($locationId)
102
    {
103
        try {
104
            return $this->innerGateway->getChildren($locationId);
105
        } catch (DBALException | PDOException $e) {
106
            throw DatabaseException::wrap($e);
107
        }
108
    }
109
110
    public function moveSubtreeNodes(array $fromPathString, array $toPathString)
111
    {
112
        try {
113
            return $this->innerGateway->moveSubtreeNodes($fromPathString, $toPathString);
114
        } catch (DBALException | PDOException $e) {
115
            throw DatabaseException::wrap($e);
116
        }
117
    }
118
119
    public function updateSubtreeModificationTime($pathString, $timestamp = null)
120
    {
121
        try {
122
            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...
123
        } catch (DBALException | PDOException $e) {
124
            throw DatabaseException::wrap($e);
125
        }
126
    }
127
128
    public function updateNodeAssignment($contentObjectId, $oldParent, $newParent, $opcode)
129
    {
130
        try {
131
            return $this->innerGateway->updateNodeAssignment($contentObjectId, $oldParent, $newParent, $opcode);
132
        } catch (DBALException | PDOException $e) {
133
            throw DatabaseException::wrap($e);
134
        }
135
    }
136
137
    public function createLocationsFromNodeAssignments($contentId, $versionNo)
138
    {
139
        try {
140
            return $this->innerGateway->createLocationsFromNodeAssignments($contentId, $versionNo);
141
        } catch (DBALException | PDOException $e) {
142
            throw DatabaseException::wrap($e);
143
        }
144
    }
145
146
    public function updateLocationsContentVersionNo($contentId, $versionNo)
147
    {
148
        try {
149
            return $this->innerGateway->updateLocationsContentVersionNo($contentId, $versionNo);
150
        } catch (DBALException | PDOException $e) {
151
            throw DatabaseException::wrap($e);
152
        }
153
    }
154
155
    public function hideSubtree($pathString)
156
    {
157
        try {
158
            return $this->innerGateway->hideSubtree($pathString);
159
        } catch (DBALException | PDOException $e) {
160
            throw DatabaseException::wrap($e);
161
        }
162
    }
163
164
    public function unHideSubtree($pathString)
165
    {
166
        try {
167
            return $this->innerGateway->unHideSubtree($pathString);
168
        } catch (DBALException | PDOException $e) {
169
            throw DatabaseException::wrap($e);
170
        }
171
    }
172
173
    public function setNodeWithChildrenInvisible(string $pathString): void
174
    {
175
        try {
176
            $this->innerGateway->setNodeWithChildrenInvisible($pathString);
177
        } catch (DBALException | PDOException $e) {
178
            throw DatabaseException::wrap($e);
179
        }
180
    }
181
182
    public function setNodeHidden(string $pathString): void
183
    {
184
        try {
185
            $this->innerGateway->setNodeHidden($pathString);
186
        } catch (DBALException | PDOException $e) {
187
            throw DatabaseException::wrap($e);
188
        }
189
    }
190
191
    public function setNodeWithChildrenVisible(string $pathString): void
192
    {
193
        try {
194
            $this->innerGateway->setNodeWithChildrenVisible($pathString);
195
        } catch (DBALException | PDOException $e) {
196
            throw DatabaseException::wrap($e);
197
        }
198
    }
199
200
    public function setNodeUnhidden(string $pathString): void
201
    {
202
        try {
203
            $this->innerGateway->setNodeUnhidden($pathString);
204
        } catch (DBALException | PDOException $e) {
205
            throw DatabaseException::wrap($e);
206
        }
207
    }
208
209
    public function swap(int $locationId1, int $locationId2): bool
210
    {
211
        try {
212
            return $this->innerGateway->swap($locationId1, $locationId2);
213
        } catch (DBALException | PDOException $e) {
214
            throw DatabaseException::wrap($e);
215
        }
216
    }
217
218
    public function create(CreateStruct $createStruct, array $parentNode)
219
    {
220
        try {
221
            return $this->innerGateway->create($createStruct, $parentNode);
222
        } catch (DBALException | PDOException $e) {
223
            throw DatabaseException::wrap($e);
224
        }
225
    }
226
227
    public function createNodeAssignment(CreateStruct $createStruct, $parentNodeId, $type = self::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP)
228
    {
229
        try {
230
            return $this->innerGateway->createNodeAssignment($createStruct, $parentNodeId, $type);
231
        } catch (DBALException | PDOException $e) {
232
            throw DatabaseException::wrap($e);
233
        }
234
    }
235
236
    public function deleteNodeAssignment($contentId, $versionNo = null)
237
    {
238
        try {
239
            return $this->innerGateway->deleteNodeAssignment($contentId, $versionNo);
240
        } catch (DBALException | PDOException $e) {
241
            throw DatabaseException::wrap($e);
242
        }
243
    }
244
245
    public function update(UpdateStruct $location, $locationId)
246
    {
247
        try {
248
            return $this->innerGateway->update($location, $locationId);
249
        } catch (DBALException | PDOException $e) {
250
            throw DatabaseException::wrap($e);
251
        }
252
    }
253
254
    public function updatePathIdentificationString($locationId, $parentLocationId, $text)
255
    {
256
        try {
257
            return $this->innerGateway->updatePathIdentificationString($locationId, $parentLocationId, $text);
258
        } catch (DBALException | PDOException $e) {
259
            throw DatabaseException::wrap($e);
260
        }
261
    }
262
263
    public function removeLocation($locationId)
264
    {
265
        try {
266
            return $this->innerGateway->removeLocation($locationId);
267
        } catch (DBALException | PDOException $e) {
268
            throw DatabaseException::wrap($e);
269
        }
270
    }
271
272
    public function getFallbackMainNodeData($contentId, $locationId)
273
    {
274
        try {
275
            return $this->innerGateway->getFallbackMainNodeData($contentId, $locationId);
276
        } catch (DBALException | PDOException $e) {
277
            throw DatabaseException::wrap($e);
278
        }
279
    }
280
281
    public function trashLocation($locationId)
282
    {
283
        try {
284
            return $this->innerGateway->trashLocation($locationId);
285
        } catch (DBALException | PDOException $e) {
286
            throw DatabaseException::wrap($e);
287
        }
288
    }
289
290
    public function untrashLocation($locationId, $newParentId = null)
291
    {
292
        try {
293
            return $this->innerGateway->untrashLocation($locationId, $newParentId);
294
        } catch (DBALException | PDOException $e) {
295
            throw DatabaseException::wrap($e);
296
        }
297
    }
298
299
    public function loadTrashByLocation($locationId)
300
    {
301
        try {
302
            return $this->innerGateway->loadTrashByLocation($locationId);
303
        } catch (DBALException | PDOException $e) {
304
            throw DatabaseException::wrap($e);
305
        }
306
    }
307
308
    public function cleanupTrash()
309
    {
310
        try {
311
            return $this->innerGateway->cleanupTrash();
312
        } catch (DBALException | PDOException $e) {
313
            throw DatabaseException::wrap($e);
314
        }
315
    }
316
317
    public function listTrashed($offset, $limit, array $sort = null)
318
    {
319
        try {
320
            return $this->innerGateway->listTrashed($offset, $limit, $sort);
321
        } catch (DBALException | PDOException $e) {
322
            throw DatabaseException::wrap($e);
323
        }
324
    }
325
326
    public function countTrashed(): int
327
    {
328
        try {
329
            return $this->innerGateway->countTrashed();
330
        } catch (DBALException | PDOException $e) {
331
            throw DatabaseException::wrap($e);
332
        }
333
    }
334
335
    public function removeElementFromTrash($id)
336
    {
337
        try {
338
            return $this->innerGateway->removeElementFromTrash($id);
339
        } catch (DBALException | PDOException $e) {
340
            throw DatabaseException::wrap($e);
341
        }
342
    }
343
344
    public function setSectionForSubtree($pathString, $sectionId)
345
    {
346
        try {
347
            return $this->innerGateway->setSectionForSubtree($pathString, $sectionId);
348
        } catch (DBALException | PDOException $e) {
349
            throw DatabaseException::wrap($e);
350
        }
351
    }
352
353
    public function countLocationsByContentId($contentId)
354
    {
355
        try {
356
            return $this->innerGateway->countLocationsByContentId($contentId);
357
        } catch (DBALException | PDOException $e) {
358
            throw DatabaseException::wrap($e);
359
        }
360
    }
361
362
    public function changeMainLocation($contentId, $locationId, $versionNo, $parentLocationId)
363
    {
364
        try {
365
            return $this->innerGateway->changeMainLocation($contentId, $locationId, $versionNo, $parentLocationId);
366
        } catch (DBALException | PDOException $e) {
367
            throw DatabaseException::wrap($e);
368
        }
369
    }
370
371
    public function countAllLocations()
372
    {
373
        try {
374
            return $this->innerGateway->countAllLocations();
375
        } catch (DBALException | PDOException $e) {
376
            throw DatabaseException::wrap($e);
377
        }
378
    }
379
380
    public function loadAllLocationsData($offset, $limit)
381
    {
382
        try {
383
            return $this->innerGateway->loadAllLocationsData($offset, $limit);
384
        } catch (DBALException | PDOException $e) {
385
            throw DatabaseException::wrap($e);
386
        }
387
    }
388
}
389