mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
Prevent multiples sub-queries.
This commit is contained in:
parent
e1f8aa5a5e
commit
ef6c5870b5
@ -15,7 +15,13 @@ final class FlatHierarchyEntityHydrator extends ObjectHydrator
|
|||||||
{
|
{
|
||||||
$generator = $this->buildRecursively(
|
$generator = $this->buildRecursively(
|
||||||
parent::hydrateAllData(),
|
parent::hydrateAllData(),
|
||||||
static fn($value): iterable => $value->getChildren(),
|
static function($value): iterable {
|
||||||
|
$children = $value->getChildren();
|
||||||
|
|
||||||
|
$children->setInitialized(true);
|
||||||
|
|
||||||
|
return $children;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
|
@ -6,6 +6,7 @@ use Chill\MainBundle\CRUD\Controller\ApiController;
|
|||||||
use Chill\MainBundle\Doctrine\ORM\Hydration\FlatHierarchyEntityHydrator;
|
use Chill\MainBundle\Doctrine\ORM\Hydration\FlatHierarchyEntityHydrator;
|
||||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
@ -26,7 +27,10 @@ class SocialIssueApiController extends ApiController
|
|||||||
{
|
{
|
||||||
// In order to work, this hydrator only works with
|
// In order to work, this hydrator only works with
|
||||||
// entities having the field "children" set up.
|
// entities having the field "children" set up.
|
||||||
return $query->getQuery()->getResult(FlatHierarchyEntityHydrator::LIST);
|
return $query
|
||||||
|
->getQuery()
|
||||||
|
->setHint(Query::HINT_INCLUDE_META_COLUMNS, true)
|
||||||
|
->getResult(FlatHierarchyEntityHydrator::LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function onPostIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query): ?Response
|
protected function onPostIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query): ?Response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user