<?php

namespace App\Controller;

use App\Repository\HeroRepository;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\AbstractFOSRestController;
use Symfony\Component\HttpFoundation\Response;

class HeroController extends AbstractFOSRestController
{
    protected $heroRepository;
    
    public function __construct(HeroRepository $heroRepository)
    {
        $this->heroRepository = $heroRepository;
    }
    
    /**
     * @Rest\Route("api/heroes")
     * @Rest\View()
     */
    public function cgetAction()
    {
        $heroes = $this->heroRepository->findAll();
        return $this->view($heroes, Response::HTTP_OK);
    }
}