From bc5f6473080429e0a469b84304e7dfd9c72918d4 Mon Sep 17 00:00:00 2001 From: "Andrew (Andrius) Marcinkevicius" Date: Sun, 28 Dec 2014 21:03:07 +0200 Subject: [PATCH 1/2] Misc changes --- best_practices/controllers.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/best_practices/controllers.rst b/best_practices/controllers.rst index 369d7be4e4c..c8e1f0c0750 100644 --- a/best_practices/controllers.rst +++ b/best_practices/controllers.rst @@ -111,7 +111,7 @@ for the homepage of our app: public function indexAction() { $em = $this->getDoctrine()->getManager(); - $posts = $em->getRepository('App:Post')->findLatest(); + $posts = $em->getRepository('AppBundle:Post')->findLatest(); return $this->render('default/index.html.twig', array( 'posts' => $posts @@ -136,6 +136,7 @@ For example: .. code-block:: php + use AppBundle\Entity\Post; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; /** @@ -146,7 +147,7 @@ For example: $deleteForm = $this->createDeleteForm($post); return $this->render('admin/post/show.html.twig', array( - 'post' => $post, + 'post' => $post, 'delete_form' => $deleteForm->createView(), )); } @@ -174,7 +175,8 @@ manually. In our application, we have this situation in ``CommentController``: { $post = $this->getDoctrine() ->getRepository('AppBundle:Post') - ->findOneBy(array('slug' => $postSlug)); + ->findOneBy(array('slug' => $postSlug)) + ; if (!$post) { throw $this->createNotFoundException(); @@ -188,8 +190,10 @@ flexible: .. code-block:: php + use AppBundle\Entity\Post; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; + use Symfony\Component\HttpFoundation\Request; /** * @Route("/comment/{postSlug}/new", name = "comment_new") From 4185b788bc780dcb3ea4314abe4198754c6a1400 Mon Sep 17 00:00:00 2001 From: "Andrew (Andrius) Marcinkevicius" Date: Mon, 29 Dec 2014 16:09:05 +0200 Subject: [PATCH 2/2] Update controllers.rst --- best_practices/controllers.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/best_practices/controllers.rst b/best_practices/controllers.rst index c8e1f0c0750..07bdf5ebb8e 100644 --- a/best_practices/controllers.rst +++ b/best_practices/controllers.rst @@ -110,8 +110,9 @@ for the homepage of our app: */ public function indexAction() { - $em = $this->getDoctrine()->getManager(); - $posts = $em->getRepository('AppBundle:Post')->findLatest(); + $posts = $this->getDoctrine() + ->getRepository('AppBundle:Post') + ->findLatest(); return $this->render('default/index.html.twig', array( 'posts' => $posts @@ -175,8 +176,7 @@ manually. In our application, we have this situation in ``CommentController``: { $post = $this->getDoctrine() ->getRepository('AppBundle:Post') - ->findOneBy(array('slug' => $postSlug)) - ; + ->findOneBy(array('slug' => $postSlug)); if (!$post) { throw $this->createNotFoundException();