animegame/src/Controller/UserController.php

30 lines
670 B

<?php
namespace App\Controller;
use App\Repository\UserRepository;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\AbstractFOSRestController;
use Symfony\Component\HttpFoundation\Response;
class UserController extends AbstractFOSRestController
{
protected $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
/**
* @Rest\Route("api/users")
* @Rest\View()
*/
public function cgetAction()
{
$users = $this->userRepository->findAll();
return $this->view($users, Response::HTTP_OK);
}
}