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 loadAllLocationEntries(int $locationId): array |
48
|
|
|
{ |
49
|
|
|
try { |
50
|
|
|
return $this->innerGateway->loadAllLocationEntries($locationId); |
51
|
|
|
} catch (DBALException | PDOException $e) { |
52
|
|
|
throw DatabaseException::wrap($e); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function loadLocationEntries( |
57
|
|
|
int $locationId, |
58
|
|
|
bool $custom = false, |
59
|
|
|
?int $languageId = null |
60
|
|
|
): array { |
61
|
|
|
try { |
62
|
|
|
return $this->innerGateway->loadLocationEntries($locationId, $custom); |
63
|
|
|
} catch (DBALException | PDOException $e) { |
64
|
|
|
throw DatabaseException::wrap($e); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function isRootEntry(int $id): bool |
69
|
|
|
{ |
70
|
|
|
try { |
71
|
|
|
return $this->innerGateway->isRootEntry($id); |
72
|
|
|
} catch (DBALException | PDOException $e) { |
73
|
|
|
throw DatabaseException::wrap($e); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function cleanupAfterPublish( |
78
|
|
|
string $action, |
79
|
|
|
int $languageId, |
80
|
|
|
int $newId, |
81
|
|
|
int $parentId, |
82
|
|
|
string $textMD5 |
83
|
|
|
): void { |
84
|
|
|
try { |
85
|
|
|
$this->innerGateway->cleanupAfterPublish($action, $languageId, $newId, $parentId, $textMD5); |
86
|
|
|
} catch (DBALException | PDOException $e) { |
87
|
|
|
throw DatabaseException::wrap($e); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function historizeBeforeSwap(string $action, int $languageMask): void |
92
|
|
|
{ |
93
|
|
|
try { |
94
|
|
|
$this->innerGateway->historizeBeforeSwap($action, $languageMask); |
95
|
|
|
} catch (DBALException | PDOException $e) { |
96
|
|
|
throw DatabaseException::wrap($e); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function historizeId(int $id, int $link): void |
101
|
|
|
{ |
102
|
|
|
try { |
103
|
|
|
$this->innerGateway->historizeId($id, $link); |
104
|
|
|
} catch (DBALException | PDOException $e) { |
105
|
|
|
throw DatabaseException::wrap($e); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function reparent(int $oldParentId, int $newParentId): void |
110
|
|
|
{ |
111
|
|
|
try { |
112
|
|
|
$this->innerGateway->reparent($oldParentId, $newParentId); |
113
|
|
|
} catch (DBALException | PDOException $e) { |
114
|
|
|
throw DatabaseException::wrap($e); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function updateRow(int $parentId, string $textMD5, array $values): void |
119
|
|
|
{ |
120
|
|
|
try { |
121
|
|
|
$this->innerGateway->updateRow($parentId, $textMD5, $values); |
122
|
|
|
} catch (DBALException | PDOException $e) { |
123
|
|
|
throw DatabaseException::wrap($e); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function insertRow(array $values): int |
128
|
|
|
{ |
129
|
|
|
try { |
130
|
|
|
return $this->innerGateway->insertRow($values); |
131
|
|
|
} catch (DBALException | PDOException $e) { |
132
|
|
|
throw DatabaseException::wrap($e); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function loadRow(int $parentId, string $textMD5): array |
137
|
|
|
{ |
138
|
|
|
try { |
139
|
|
|
return $this->innerGateway->loadRow($parentId, $textMD5); |
140
|
|
|
} catch (DBALException | PDOException $e) { |
141
|
|
|
throw DatabaseException::wrap($e); |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function loadAutogeneratedEntry(string $action, ?int $parentId = null): array |
146
|
|
|
{ |
147
|
|
|
try { |
148
|
|
|
return $this->innerGateway->loadAutogeneratedEntry($action, $parentId); |
149
|
|
|
} catch (DBALException | PDOException $e) { |
150
|
|
|
throw DatabaseException::wrap($e); |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function remove(string $action, ?int $id = null): void |
155
|
|
|
{ |
156
|
|
|
try { |
157
|
|
|
$this->innerGateway->remove($action, $id); |
158
|
|
|
} catch (DBALException | PDOException $e) { |
159
|
|
|
throw DatabaseException::wrap($e); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function listGlobalEntries( |
164
|
|
|
?string $languageCode = null, |
165
|
|
|
int $offset = 0, |
166
|
|
|
int $limit = -1 |
167
|
|
|
): array { |
168
|
|
|
try { |
169
|
|
|
return $this->innerGateway->listGlobalEntries($languageCode, $offset, $limit); |
170
|
|
|
} catch (DBALException | PDOException $e) { |
171
|
|
|
throw DatabaseException::wrap($e); |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function removeCustomAlias(int $parentId, string $textMD5): bool |
176
|
|
|
{ |
177
|
|
|
try { |
178
|
|
|
return $this->innerGateway->removeCustomAlias($parentId, $textMD5); |
179
|
|
|
} catch (DBALException | PDOException $e) { |
180
|
|
|
throw DatabaseException::wrap($e); |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
public function loadUrlAliasData(array $urlHashes): array |
185
|
|
|
{ |
186
|
|
|
try { |
187
|
|
|
return $this->innerGateway->loadUrlAliasData($urlHashes); |
188
|
|
|
} catch (DBALException | PDOException $e) { |
189
|
|
|
throw DatabaseException::wrap($e); |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
public function loadPathData(int $id): array |
194
|
|
|
{ |
195
|
|
|
try { |
196
|
|
|
return $this->innerGateway->loadPathData($id); |
197
|
|
|
} catch (DBALException | PDOException $e) { |
198
|
|
|
throw DatabaseException::wrap($e); |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
public function loadPathDataByHierarchy(array $hierarchyData): array |
203
|
|
|
{ |
204
|
|
|
try { |
205
|
|
|
return $this->innerGateway->loadPathDataByHierarchy($hierarchyData); |
206
|
|
|
} catch (DBALException | PDOException $e) { |
207
|
|
|
throw DatabaseException::wrap($e); |
208
|
|
|
} |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
public function loadAutogeneratedEntries(int $parentId, bool $includeHistory = false): array |
212
|
|
|
{ |
213
|
|
|
try { |
214
|
|
|
return $this->innerGateway->loadAutogeneratedEntries($parentId, $includeHistory); |
215
|
|
|
} catch (DBALException | PDOException $e) { |
216
|
|
|
throw DatabaseException::wrap($e); |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
public function getNextId(): int |
221
|
|
|
{ |
222
|
|
|
try { |
223
|
|
|
return $this->innerGateway->getNextId(); |
224
|
|
|
} catch (DBALException | PDOException $e) { |
225
|
|
|
throw DatabaseException::wrap($e); |
226
|
|
|
} |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
public function getLocationContentMainLanguageId(int $locationId): int |
230
|
|
|
{ |
231
|
|
|
try { |
232
|
|
|
return $this->innerGateway->getLocationContentMainLanguageId($locationId); |
233
|
|
|
} catch (DBALException | PDOException $e) { |
234
|
|
|
throw DatabaseException::wrap($e); |
235
|
|
|
} |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
public function bulkRemoveTranslation(int $languageId, array $actions): void |
239
|
|
|
{ |
240
|
|
|
try { |
241
|
|
|
$this->innerGateway->bulkRemoveTranslation($languageId, $actions); |
242
|
|
|
} catch (DBALException | PDOException $e) { |
243
|
|
|
throw DatabaseException::wrap($e); |
244
|
|
|
} |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
public function archiveUrlAliasesForDeletedTranslations( |
248
|
|
|
int $locationId, |
249
|
|
|
int $parentId, |
250
|
|
|
array $languageIds |
251
|
|
|
): void { |
252
|
|
|
try { |
253
|
|
|
$this->innerGateway->archiveUrlAliasesForDeletedTranslations($locationId, $parentId, $languageIds); |
254
|
|
|
} catch (DBALException | PDOException $e) { |
255
|
|
|
throw DatabaseException::wrap($e); |
256
|
|
|
} |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
public function deleteUrlAliasesWithoutLocation(): int |
260
|
|
|
{ |
261
|
|
|
try { |
262
|
|
|
return $this->innerGateway->deleteUrlAliasesWithoutLocation(); |
263
|
|
|
} catch (DBALException | PDOException $e) { |
264
|
|
|
throw DatabaseException::wrap($e); |
265
|
|
|
} |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
public function deleteUrlAliasesWithoutParent(): int |
269
|
|
|
{ |
270
|
|
|
try { |
271
|
|
|
return $this->innerGateway->deleteUrlAliasesWithoutParent(); |
272
|
|
|
} catch (DBALException | PDOException $e) { |
273
|
|
|
throw DatabaseException::wrap($e); |
274
|
|
|
} |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
public function deleteUrlAliasesWithBrokenLink(): int |
278
|
|
|
{ |
279
|
|
|
try { |
280
|
|
|
return $this->innerGateway->deleteUrlAliasesWithBrokenLink(); |
281
|
|
|
} catch (DBALException | PDOException $e) { |
282
|
|
|
throw DatabaseException::wrap($e); |
283
|
|
|
} |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
public function repairBrokenUrlAliasesForLocation(int $locationId): void |
287
|
|
|
{ |
288
|
|
|
try { |
289
|
|
|
$this->innerGateway->repairBrokenUrlAliasesForLocation($locationId); |
290
|
|
|
} catch (DBALException | PDOException $e) { |
291
|
|
|
throw DatabaseException::wrap($e); |
292
|
|
|
} |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
public function deleteUrlNopAliasesWithoutChildren(): int |
296
|
|
|
{ |
297
|
|
|
try { |
298
|
|
|
return $this->innerGateway->deleteUrlNopAliasesWithoutChildren(); |
299
|
|
|
} catch (DBALException | PDOException $e) { |
300
|
|
|
throw DatabaseException::wrap($e); |
301
|
|
|
} |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
public function getAllChildrenAliases(int $parentId): array |
305
|
|
|
{ |
306
|
|
|
try { |
307
|
|
|
return $this->innerGateway->getAllChildrenAliases($parentId); |
308
|
|
|
} catch (DBALException | PDOException $e) { |
309
|
|
|
throw DatabaseException::wrap($e); |
310
|
|
|
} |
311
|
|
|
} |
312
|
|
|
} |
313
|
|
|
|