Skip to content

Commit cc1494b

Browse files
committed
Upgraded URL Alias Doctrine Gateway to doctrine/dbal v3 and improved code quality
1 parent 1f9cbbd commit cc1494b

File tree

3 files changed

+267
-174
lines changed

3 files changed

+267
-174
lines changed

src/lib/Persistence/Legacy/Content/UrlAlias/Gateway.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ abstract class Gateway
1818
/**
1919
* Default database table.
2020
*/
21-
public const TABLE = 'ezurlalias_ml';
21+
public const string TABLE = 'ezurlalias_ml';
2222

23-
public const INCR_TABLE = 'ezurlalias_ml_incr';
24-
public const INCR_TABLE_SEQ = 'ezurlalias_ml_incr_id_seq';
23+
public const string INCR_TABLE = 'ezurlalias_ml_incr';
24+
public const string INCR_TABLE_SEQ = 'ezurlalias_ml_incr_id_seq';
2525

26-
public const NOP = 'nop';
27-
public const NOP_ACTION = self::NOP . ':';
26+
public const string NOP = 'nop';
27+
public const string NOP_ACTION = self::NOP . ':';
2828

2929
/**
3030
* Changes the gateway database table.
@@ -37,11 +37,15 @@ abstract public function setTable(string $name): void;
3737

3838
/**
3939
* Loads all list of aliases by given $locationId.
40+
*
41+
* @phpstan-return list<array<string,mixed>>
4042
*/
4143
abstract public function loadAllLocationEntries(int $locationId): array;
4244

4345
/**
4446
* Load list of aliases by given $locationId.
47+
*
48+
* @phpstan-return list<array<string,mixed>>
4549
*/
4650
abstract public function loadLocationEntries(
4751
int $locationId,
@@ -52,6 +56,8 @@ abstract public function loadLocationEntries(
5256
/**
5357
* Load paged list of global aliases.
5458
*
59+
* @phpstan-return list<array<string,mixed>>
60+
*
5561
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException if the given language doesn't exist
5662
*/
5763
abstract public function listGlobalEntries(
@@ -63,27 +69,29 @@ abstract public function listGlobalEntries(
6369
/**
6470
* Return boolean indicating if the row with given $id is special root entry.
6571
*
66-
* Special root entry entry will have parentId=0 and text=''.
72+
* Special root entry will have parentId=0 and text=''.
6773
* In standard installation this entry will point to location with id=2.
6874
*/
6975
abstract public function isRootEntry(int $id): bool;
7076

7177
/**
7278
* Update single row data matched by composite primary key.
7379
*
74-
* @param array $values associative array with column names as keys and column values as values
80+
* @param array<string, mixed> $values associative array with column names as keys and column values as values
7581
*/
7682
abstract public function updateRow(int $parentId, string $textMD5, array $values): void;
7783

7884
/**
7985
* Insert new row into urlalias_ml table.
8086
*
81-
* @param array $values
87+
* @param array<string, mixed> $values
8288
*/
8389
abstract public function insertRow(array $values): int;
8490

8591
/**
8692
* Load single row matched by composite primary key.
93+
*
94+
* @return array<string, mixed>
8795
*/
8896
abstract public function loadRow(int $parentId, string $textMD5): array;
8997

@@ -92,7 +100,7 @@ abstract public function loadRow(int $parentId, string $textMD5): array;
92100
* composite primary key.
93101
*
94102
* If language mask of the found entry is composite (meaning it consists of multiple language ids) given
95-
* $languageId will be removed from mask. Otherwise entry will be marked as history.
103+
* $languageId will be removed from mask. Otherwise, entry will be marked as history.
96104
*/
97105
abstract public function cleanupAfterPublish(
98106
string $action,
@@ -128,6 +136,8 @@ abstract public function reparent(int $oldParentId, int $newParentId): void;
128136
/**
129137
* Load path data identified by given $id.
130138
*
139+
* @phpstan-return list<list<array<string,mixed>>>
140+
*
131141
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
132142
*/
133143
abstract public function loadPathData(int $id): array;
@@ -140,19 +150,25 @@ abstract public function loadPathData(int $id): array;
140150
* This method is faster than self::getPath() since it can fetch all elements using only one query, but can be used
141151
* only for autogenerated paths.
142152
*
143-
* @param array $hierarchyData hierarchy-ordered URL alias entries data
153+
* @phpstan-param list<array{id: int, parent: int, action: string}> $hierarchyData hierarchy-ordered URL alias entries data
154+
*
155+
* @phpstan-return list<list<array<string, mixed>>>
144156
*/
145157
abstract public function loadPathDataByHierarchy(array $hierarchyData): array;
146158

147159
/**
148160
* Load complete URL alias data by given array of path hashes.
149161
*
150162
* @param string[] $urlHashes URL string hashes
163+
*
164+
* @return array<string, mixed>
151165
*/
152166
abstract public function loadUrlAliasData(array $urlHashes): array;
153167

154168
/**
155169
* Load autogenerated entry id by given $action and optionally $parentId.
170+
*
171+
* @return array<string, mixed>
156172
*/
157173
abstract public function loadAutogeneratedEntry(string $action, ?int $parentId = null): array;
158174

@@ -170,6 +186,8 @@ abstract public function remove(string $action, ?int $id = null): void;
170186

171187
/**
172188
* Load all autogenerated entries with given $parentId with optionally included history entries.
189+
*
190+
* @phpstan-return list<array<string,mixed>>
173191
*/
174192
abstract public function loadAutogeneratedEntries(
175193
int $parentId,
@@ -235,6 +253,8 @@ abstract public function deleteUrlNopAliasesWithoutChildren(): int;
235253

236254
/**
237255
* Return aliases which are connected with provided parentId.
256+
*
257+
* @phpstan-return list<array<string,mixed>>
238258
*/
239259
abstract public function getAllChildrenAliases(int $parentId): array;
240260

0 commit comments

Comments
 (0)