location: filter location-type by active and availableForUsers

This commit is contained in:
nobohan 2021-11-03 10:27:58 +01:00 committed by Julien Fastré
parent 0439e6a821
commit e52880bb53
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<?php
namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Symfony\Component\HttpFoundation\Request;
/**
* Class LocationTypeApiController
*
* @package Chill\MainBundle\Controller
* @author Champs Libres
*/
class LocationTypeApiController extends ApiController
{
public function customizeQuery(string $action, Request $request, $query): void
{
$query->andWhere(
$query->expr()->andX(
$query->expr()->eq('e.availableForUsers', "'TRUE'"),
$query->expr()->eq('e.active', "'TRUE'"),
)
);
}
}

View File

@ -526,6 +526,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
],
[
'class' => \Chill\MainBundle\Entity\LocationType::class,
'controller' => \Chill\MainBundle\Controller\LocationTypeApiController::class,
'name' => 'location_type',
'base_path' => '/api/1.0/main/location-type',
'base_role' => 'ROLE_USER',