Skip to content

Commit

Permalink
Fix compatibility issues with Doctrine.
Browse files Browse the repository at this point in the history
  • Loading branch information
ouss-oud committed Aug 25, 2024
1 parent 6bd4e3d commit a547f06
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Entity/TransUnitRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,19 @@ public function getTransUnitList(array $locales = null, $rows = 20, $page = 1, a
/**
* Count the number of trans unit.
*
* @param array<string, mixed> $criteria
* @return int
*/
public function count(array $locales = null, array $filters = null)
public function count(array $criteria = []): int
{
$this->loadCustomHydrator();

$builder = $this->createQueryBuilder('tu')
->select('COUNT(DISTINCT tu.id) AS number');

$locales = $criteria['locales'] ?? null;
$filters = $criteria['filters'] ?? null;

$this->addTransUnitFilters($builder, $filters);
$this->addTranslationFilter($builder, $locales, $filters);

Expand Down
13 changes: 12 additions & 1 deletion Util/Doctrine/SingleColumnArrayHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Lexik\Bundle\TranslationBundle\Util\Doctrine;

use Doctrine\DBAL\Result;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;

/**
Expand All @@ -14,7 +16,7 @@ class SingleColumnArrayHydrator extends AbstractHydrator
/**
* {@inheritdoc}
*/
protected function hydrateAllData()
protected function hydrateAllData(): mixed
{
$result = [];

Expand All @@ -34,4 +36,13 @@ protected function hydrateAllData()

return $result;
}

/**
* {@inheritdoc}
*/
public function hydrateAll(Result $stmt, ResultSetMapping $resultSetMapping, array $hints = []): mixed
{
$this->_stmt = $stmt;
return parent::hydrateAll($stmt, $resultSetMapping, $hints);
}
}

0 comments on commit a547f06

Please sign in to comment.