21.10.2015 Views

1-33

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Symfony2 – Franz Jordán 2011<br />

$posts = $this->get('doctrine')->getEntityManager()<br />

->createQuery('SELECT p FROM AcmeBlogBundle:Post p')<br />

->execute();<br />

return $this->render('AcmeBlogBundle:Post:list.html.php',<br />

array('posts' => $posts));<br />

}<br />

public function showAction($id)<br />

{<br />

$post = $this->get('doctrine')<br />

->getEntityManager()<br />

->getRepository('AcmeBlogBundle:Post')<br />

->find($id);<br />

if (!$post) {<br />

// cause the 404 page not found to be displayed<br />

throw $this->createNotFoundException();<br />

}<br />

=> $post));<br />

return $this->render('AcmeBlogBundle:Post:show.html.php', array('post'<br />

}<br />

}<br />

25

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!