Skip to content

Commit 257d446

Browse files
authored
feat: improve abtract doctrine storage. Superseed #468 (#475)
1 parent 0a6e172 commit 257d446

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Storage/AbstractDoctrineStorage.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,23 +156,33 @@ public function getTransUnitDomainsByLocale()
156156
*/
157157
public function getTransUnitsByLocaleAndDomain($locale, $domain): array
158158
{
159-
return $this->getTransUnitRepository()->getAllByLocaleAndDomain($locale, $domain);
159+
return $this->getTransUnitRepository()->getAllByLocaleAndDomain(locale: $locale, domain: $domain);
160160
}
161161

162162
/**
163163
* {@inheritdoc}
164164
*/
165-
public function getTransUnitList(?array $locales = null, $rows = 20, $page = 1, ?array $filters = null): array
165+
public function getTransUnitList(?array $locales = null, ?int $rows = 20, ?int $page = 1, ?array $filters = null): array
166166
{
167-
return $this->getTransUnitRepository()->getTransUnitList($locales, $rows, $page, $filters);
167+
return $this->getTransUnitRepository()->getTransUnitList(locales: $locales, rows: $rows, page: $page, filters: $filters);
168168
}
169169

170170
/**
171171
* {@inheritdoc}
172172
*/
173173
public function countTransUnits(?array $locales = null, ?array $filters = null): int
174174
{
175-
return $this->getTransUnitRepository()->count($locales, $filters);
175+
$criteria = [
176+
'locales' => $locales,
177+
'filters' => $filters,
178+
];
179+
if (null === $locales) {
180+
unset($criteria['locales']);
181+
}
182+
if (null === $filters) {
183+
unset($criteria['filters']);
184+
}
185+
return $this->getTransUnitRepository()->count(criteria: $criteria);
176186
}
177187

178188
/**

Storage/StorageInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function getTransUnitsByLocaleAndDomain($locale, $domain): array;
114114
* @param int $page
115115
* @return array
116116
*/
117-
public function getTransUnitList(?array $locales = null, $rows = 20, $page = 1, ?array $filters = null): array;
117+
public function getTransUnitList(?array $locales = null, ?int $rows = 20, ?int $page = 1, ?array $filters = null): array;
118118

119119
/**
120120
* Count the number of trans unit.

0 commit comments

Comments
 (0)