chill-bundles/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php
2021-11-23 14:08:50 +01:00

37 lines
1.0 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 Chill\MainBundle\Pagination\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Class AddressReferenceAPIController.
*/
class AddressReferenceAPIController extends ApiController
{
protected function customizeQuery(string $action, Request $request, $qb): void
{
if ($request->query->has('postal_code')) {
$qb->where('e.postcode = :postal_code')
->setParameter('postal_code', $request->query->get('postal_code'));
}
}
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format)
{
$query->addOrderBy('e.street', 'ASC');
$query->addOrderBy('e.streetNumber', 'ASC');
return $query;
}
}