Skip to content
Snippets Groups Projects
Commit 345a99e1 authored by Moreau Elise's avatar Moreau Elise
Browse files

add class to return contaminated users in a group in json

parent 6991656a
Branches
No related tags found
No related merge requests found
<?php
declare(strict_types=1);
namespace App\Application\Actions\User;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\MiddlewareInterface as Middleware;
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
use Slim\Exception\HttpBadRequestException;
/**
* Class ListUsersAction
*
* @author : moreau96u
*/
class UsersToJson extends UserAction
{
protected function action(): Response
{
$groupId = (int) $this->resolveArg('id');
$qb = $this->em->createQueryBuilder()
->select('u')
->from('App\Domain\User\User', 'u')
->where('u.contaminated = 1')
->andWhere(':targetGroup MEMBER OF u.groups')
->setParameter('targetGroup', $groupId)
->getQuery()
->getResult();
return $this->respondWithData($qb);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment