mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-05 08:26:13 +00:00
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Chill\PersonBundle\Controller;
|
|
|
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
use Chill\MainBundle\Doctrine\ORM\Hydration\FlatHierarchyEntityHydrator;
|
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
|
use DateTimeImmutable;
|
|
use Doctrine\ORM\Query;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class SocialIssueApiController extends ApiController
|
|
{
|
|
protected function customizeQuery(string $action, Request $request, $query): void
|
|
{
|
|
$query->where(
|
|
$query->expr()->orX(
|
|
$query->expr()->gt('e.desactivationDate', ':now'),
|
|
$query->expr()->isNull('e.desactivationDate')
|
|
)
|
|
);
|
|
$query->setParameter('now', new DateTimeImmutable());
|
|
}
|
|
|
|
protected function getQueryResult(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query)
|
|
{
|
|
// In order to work, this hydrator only works with
|
|
// entities having the field "children" set up.
|
|
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
|
|
{
|
|
$query
|
|
->orderBy("GET_JSON_FIELD_BY_KEY(e.title, :locale)", 'ASC')
|
|
->setParameter(':locale', $request->getLocale());
|
|
|
|
return null;
|
|
}
|
|
}
|