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.
32 lines
713 B
32 lines
713 B
6 years ago
|
<?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);
|
||
|
}
|
||
|
}
|