Commit 5a904643 authored by François Agneray's avatar François Agneray
Browse files

Add user list endpoint (list all users)

parent 75d13d23
......@@ -76,6 +76,10 @@ $container->set('App\Action\ProjectAction', function (ContainerInterface $c) {
return new App\Action\ProjectAction($c->get('em'));
$container->set('App\Action\UserListAction', function (ContainerInterface $c) {
return new App\Action\UserListAction($c->get('em'));
$container->set('App\Action\GroupListAction', function (ContainerInterface $c) {
return new App\Action\GroupListAction($c->get('em'));
......@@ -18,6 +18,7 @@ $app->map([OPTIONS, GET, PUT, DELETE], '/database/{id}', App\Action\DatabaseActi
$app->map([OPTIONS, GET], '/database/{id}/table', App\Action\TableListAction::class);
$app->map([OPTIONS, GET, POST], '/project', App\Action\ProjectListAction::class);
$app->map([OPTIONS, GET, PUT, DELETE], '/project/{name}', App\Action\ProjectAction::class);
$app->map([OPTIONS, GET], '/user', App\Action\UserListAction::class);
$app->map([OPTIONS, GET, POST], '/group', App\Action\GroupListAction::class);
$app->map([OPTIONS, GET, POST], '/group/{id}', App\Action\GroupAction::class);
$app->map([OPTIONS, GET, POST], '/instance', App\Action\InstanceListAction::class);
* This file is part of Anis Server.
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
namespace App\Action;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Slim\Exception\HttpBadRequestException;
use App\Entity\User;
final class UserListAction extends AbstractAction
* `GET` Returns a list of all users listed in the metamodel
* @param ServerRequestInterface $request PSR-7 This object represents the HTTP request
* @param ResponseInterface $response PSR-7 This object represents the HTTP response
* @param string[] $args This table contains information transmitted in the URL (see routes.php)
* @return ResponseInterface
public function __invoke(Request $request, Response $response, array $args): Response
if ($request->getMethod() === OPTIONS) {
return $response->withHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
if ($request->getMethod() === GET) {
$users = $this->em->getRepository('App\Entity\User')->findAll();
$payload = json_encode($users);
return $response;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment