You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			31 lines
		
	
	
		
			662 B
		
	
	
	
		
			PHP
		
	
			
		
		
	
	
			31 lines
		
	
	
		
			662 B
		
	
	
	
		
			PHP
		
	
| <?php
 | |
| 
 | |
| namespace App\Controller;
 | |
| 
 | |
| use App\Repository\HeroRepository;
 | |
| use FOS\RestBundle\Controller\Annotations as Rest;
 | |
| use FOS\RestBundle\Controller\FOSRestController;
 | |
| 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()
 | |
|     {
 | |
|         $heroes = $this->heroRepository->findAll();
 | |
|         return $this->view($heroes, Response::HTTP_OK);
 | |
|     }
 | |
| }
 |