You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
animegame/src/Controller/HeroController.php

32 lines
713 B

<?php
namespace App\Controller;
use App\Entity\Repository\HeroRepository;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* @Rest\RouteResource("Hero")
*/
class HeroController extends FOSRestController
{
protected $heroRepository;
public function __construct(HeroRepository $heroRepository)
{
$this->heroRepository = $heroRepository;
}
/**
* @Rest\View()
*/
public function cgetAction()
{
$heros = $this->heroRepository->findAll();
return $this->view($heros, Response::HTTP_OK);
}
}