Skip to content

Commit

Permalink
[7-18] ConcertControllerのgetConcertsAction()メソッドを実装
Browse files Browse the repository at this point in the history
  • Loading branch information
hidenorigoto committed Dec 28, 2015
1 parent c79751f commit ae88e36
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/lists/ch07/07-18.txt
@@ -0,0 +1,18 @@
...
use FOS\RestBundle\View\View;

...
class ConcertController extends FOSRestController
{
...
public function getConcertsAction()
{
$em = $this->get('doctrine')->getManager();
$repository = $em->getRepository('AppBundle:Concert');
$concertList = $repository->findAll();

$view = new View($concertList);

return $this->handleView($view);
}
}
8 changes: 8 additions & 0 deletions src/AppBundle/Controller/Api/ConcertController.php
Expand Up @@ -3,6 +3,7 @@

use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\View\View;

class ConcertController extends FOSRestController
{
Expand All @@ -11,5 +12,12 @@ class ConcertController extends FOSRestController
*/
public function getConcertsAction()
{
$em = $this->get('doctrine')->getManager();
$repository = $em->getRepository('AppBundle:Concert');
$concertList = $repository->findAll();

$view = new View($concertList);

return $this->handleView($view);
}
}

0 comments on commit ae88e36

Please sign in to comment.