Completed
Push — master ( 01e425...9680ce )
by
unknown
13:57 queued 15s
created

deleteUrlNopAliasesWithoutChildren()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 2
dl 0
loc 8
c 0
b 0
f 0
cc 2
nop 0
rs 10
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
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway;
10
11
use eZ\Publish\Core\Base\Exceptions\DatabaseException;
12
use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway;
13
use Doctrine\DBAL\DBALException;
14
use PDOException;
15
16
/**
17
 * @internal Internal exception conversion layer.
18
 */
19
final class ExceptionConversion extends Gateway
20
{
21
    /**
22
     * The wrapped gateway.
23
     *
24
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway
25
     */
26
    private $innerGateway;
27
28
    /**
29
     * Creates a new exception conversion gateway around $innerGateway.
30
     *
31
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway $innerGateway
32
     */
33
    public function __construct(Gateway $innerGateway)
34
    {
35
        $this->innerGateway = $innerGateway;
36
    }
37
38
    public function setTable(string $name): void
39
    {
40
        try {
41
            $this->innerGateway->setTable($name);
42
        } catch (DBALException | PDOException $e) {
43
            throw DatabaseException::wrap($e);
44
        }
45
    }
46
47
    public function loadLocationEntries(
48
        int $locationId,
49
        bool $custom = false,
50
        ?int $languageId = null
51
    ): array {
52
        try {
53
            return $this->innerGateway->loadLocationEntries($locationId, $custom);
54
        } catch (DBALException | PDOException $e) {
55
            throw DatabaseException::wrap($e);
56
        }
57
    }
58
59
    public function isRootEntry(int $id): bool
60
    {
61
        try {
62
            return $this->innerGateway->isRootEntry($id);
63
        } catch (DBALException | PDOException $e) {
64
            throw DatabaseException::wrap($e);
65
        }
66
    }
67
68
    public function cleanupAfterPublish(
69
        string $action,
70
        int $languageId,
71
        int $newId,
72
        int $parentId,
73
        string $textMD5
74
    ): void {
75
        try {
76
            $this->innerGateway->cleanupAfterPublish($action, $languageId, $newId, $parentId, $textMD5);
77
        } catch (DBALException | PDOException $e) {
78
            throw DatabaseException::wrap($e);
79
        }
80
    }
81
82
    public function historizeBeforeSwap(string $action, int $languageMask): void
83
    {
84
        try {
85
            $this->innerGateway->historizeBeforeSwap($action, $languageMask);
86
        } catch (DBALException | PDOException $e) {
87
            throw DatabaseException::wrap($e);
88
        }
89
    }
90
91
    public function historizeId(int $id, int $link): void
92
    {
93
        try {
94
            $this->innerGateway->historizeId($id, $link);
95
        } catch (DBALException | PDOException $e) {
96
            throw DatabaseException::wrap($e);
97
        }
98
    }
99
100
    public function reparent(int $oldParentId, int $newParentId): void
101
    {
102
        try {
103
            $this->innerGateway->reparent($oldParentId, $newParentId);
104
        } catch (DBALException | PDOException $e) {
105
            throw DatabaseException::wrap($e);
106
        }
107
    }
108
109
    public function updateRow(int $parentId, string $textMD5, array $values): void
110
    {
111
        try {
112
            $this->innerGateway->updateRow($parentId, $textMD5, $values);
113
        } catch (DBALException | PDOException $e) {
114
            throw DatabaseException::wrap($e);
115
        }
116
    }
117
118
    public function insertRow(array $values): int
119
    {
120
        try {
121
            return $this->innerGateway->insertRow($values);
122
        } catch (DBALException | PDOException $e) {
123
            throw DatabaseException::wrap($e);
124
        }
125
    }
126
127
    public function loadRow(int $parentId, string $textMD5): array
128
    {
129
        try {
130
            return $this->innerGateway->loadRow($parentId, $textMD5);
131
        } catch (DBALException | PDOException $e) {
132
            throw DatabaseException::wrap($e);
133
        }
134
    }
135
136
    public function loadAutogeneratedEntry(string $action, ?int $parentId = null): array
137
    {
138
        try {
139
            return $this->innerGateway->loadAutogeneratedEntry($action, $parentId);
140
        } catch (DBALException | PDOException $e) {
141
            throw DatabaseException::wrap($e);
142
        }
143
    }
144
145
    public function remove(string $action, ?int $id = null): void
146
    {
147
        try {
148
            $this->innerGateway->remove($action, $id);
149
        } catch (DBALException | PDOException $e) {
150
            throw DatabaseException::wrap($e);
151
        }
152
    }
153
154
    public function listGlobalEntries(
155
        ?string $languageCode = null,
156
        int $offset = 0,
157
        int $limit = -1
158
    ): array {
159
        try {
160
            return $this->innerGateway->listGlobalEntries($languageCode, $offset, $limit);
161
        } catch (DBALException | PDOException $e) {
162
            throw DatabaseException::wrap($e);
163
        }
164
    }
165
166
    public function removeCustomAlias(int $parentId, string $textMD5): bool
167
    {
168
        try {
169
            return $this->innerGateway->removeCustomAlias($parentId, $textMD5);
170
        } catch (DBALException | PDOException $e) {
171
            throw DatabaseException::wrap($e);
172
        }
173
    }
174
175
    public function loadUrlAliasData(array $urlHashes): array
176
    {
177
        try {
178
            return $this->innerGateway->loadUrlAliasData($urlHashes);
179
        } catch (DBALException | PDOException $e) {
180
            throw DatabaseException::wrap($e);
181
        }
182
    }
183
184
    public function loadPathData(int $id): array
185
    {
186
        try {
187
            return $this->innerGateway->loadPathData($id);
188
        } catch (DBALException | PDOException $e) {
189
            throw DatabaseException::wrap($e);
190
        }
191
    }
192
193
    public function loadPathDataByHierarchy(array $hierarchyData): array
194
    {
195
        try {
196
            return $this->innerGateway->loadPathDataByHierarchy($hierarchyData);
197
        } catch (DBALException | PDOException $e) {
198
            throw DatabaseException::wrap($e);
199
        }
200
    }
201
202
    public function loadAutogeneratedEntries(int $parentId, bool $includeHistory = false): array
203
    {
204
        try {
205
            return $this->innerGateway->loadAutogeneratedEntries($parentId, $includeHistory);
206
        } catch (DBALException | PDOException $e) {
207
            throw DatabaseException::wrap($e);
208
        }
209
    }
210
211
    public function getNextId(): int
212
    {
213
        try {
214
            return $this->innerGateway->getNextId();
215
        } catch (DBALException | PDOException $e) {
216
            throw DatabaseException::wrap($e);
217
        }
218
    }
219
220
    public function getLocationContentMainLanguageId(int $locationId): int
221
    {
222
        try {
223
            return $this->innerGateway->getLocationContentMainLanguageId($locationId);
224
        } catch (DBALException | PDOException $e) {
225
            throw DatabaseException::wrap($e);
226
        }
227
    }
228
229
    public function bulkRemoveTranslation(int $languageId, array $actions): void
230
    {
231
        try {
232
            $this->innerGateway->bulkRemoveTranslation($languageId, $actions);
233
        } catch (DBALException | PDOException $e) {
234
            throw DatabaseException::wrap($e);
235
        }
236
    }
237
238
    public function archiveUrlAliasesForDeletedTranslations(
239
        int $locationId,
240
        int $parentId,
241
        array $languageIds
242
    ): void {
243
        try {
244
            $this->innerGateway->archiveUrlAliasesForDeletedTranslations($locationId, $parentId, $languageIds);
245
        } catch (DBALException | PDOException $e) {
246
            throw DatabaseException::wrap($e);
247
        }
248
    }
249
250
    public function deleteUrlAliasesWithoutLocation(): int
251
    {
252
        try {
253
            return $this->innerGateway->deleteUrlAliasesWithoutLocation();
254
        } catch (DBALException | PDOException $e) {
255
            throw DatabaseException::wrap($e);
256
        }
257
    }
258
259
    public function deleteUrlAliasesWithoutParent(): int
260
    {
261
        try {
262
            return $this->innerGateway->deleteUrlAliasesWithoutParent();
263
        } catch (DBALException | PDOException $e) {
264
            throw DatabaseException::wrap($e);
265
        }
266
    }
267
268
    public function deleteUrlAliasesWithBrokenLink(): int
269
    {
270
        try {
271
            return $this->innerGateway->deleteUrlAliasesWithBrokenLink();
272
        } catch (DBALException | PDOException $e) {
273
            throw DatabaseException::wrap($e);
274
        }
275
    }
276
277
    public function repairBrokenUrlAliasesForLocation(int $locationId): void
278
    {
279
        try {
280
            $this->innerGateway->repairBrokenUrlAliasesForLocation($locationId);
281
        } catch (DBALException | PDOException $e) {
282
            throw DatabaseException::wrap($e);
283
        }
284
    }
285
286
    public function deleteUrlNopAliasesWithoutChildren(): int
287
    {
288
        try {
289
            return $this->innerGateway->deleteUrlNopAliasesWithoutChildren();
290
        } catch (DBALException | PDOException $e) {
291
            throw DatabaseException::wrap($e);
292
        }
293
    }
294
295
    public function getAllChildrenAliases(int $parentId): array
296
    {
297
        try {
298
            return $this->innerGateway->getAllChildrenAliases($parentId);
299
        } catch (DBALException | PDOException $e) {
300
            throw DatabaseException::wrap($e);
301
        }
302
    }
303
}
304