mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 22:46:13 +00:00
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Controller;
|
|
|
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
use DateInterval;
|
|
use DateTime;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
/**
|
|
* Class LocationApiController.
|
|
*/
|
|
class LocationApiController extends ApiController
|
|
{
|
|
public function customizeQuery(string $action, Request $request, $query): void
|
|
{
|
|
$query->andWhere($query->expr()->orX(
|
|
$query->expr()->andX(
|
|
$query->expr()->eq('e.createdBy', ':user'),
|
|
$query->expr()->gte('e.createdAt', ':dateBefore')
|
|
),
|
|
$query->expr()->andX(
|
|
$query->expr()->eq('e.availableForUsers', "'TRUE'"),
|
|
$query->expr()->eq('e.active', "'TRUE'"),
|
|
$query->expr()->isNotNull('e.name'),
|
|
$query->expr()->neq('e.name', ':emptyString'),
|
|
)
|
|
))
|
|
->setParameters([
|
|
'user' => $this->getUser(),
|
|
'dateBefore' => (new DateTime())->sub(new DateInterval('P6M')),
|
|
'emptyString' => '',
|
|
]);
|
|
}
|
|
}
|