From f1f034554b73a530ebd0c83376da3b7de896f140 Mon Sep 17 00:00:00 2001 From: Richard Miller Date: Mon, 26 Nov 2012 11:51:32 +0000 Subject: [PATCH 1/2] Reducing code sample line lengths to avoid horizontal scrolling --- book/controller.rst | 35 ++++++++++++++----- book/doctrine.rst | 11 ++++-- book/forms.rst | 4 ++- book/from_flat_php_to_symfony2.rst | 20 ++++++++--- book/page_creation.rst | 14 ++++++-- book/propel.rst | 56 ++++++++++++++++-------------- book/routing.rst | 19 +++++++--- book/security.rst | 21 +++++++---- book/service_container.rst | 24 ++++++++++--- book/templating.rst | 23 +++++++++--- book/testing.rst | 37 +++++++++++++++----- book/translation.rst | 18 ++++++++-- book/validation.rst | 22 +++++++----- 13 files changed, 216 insertions(+), 88 deletions(-) diff --git a/book/controller.rst b/book/controller.rst index 273799255b4..e7d96cc0777 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -472,10 +472,12 @@ value to each variable. object:: $httpKernel = $this->container->get('http_kernel'); - $response = $httpKernel->forward('AcmeHelloBundle:Hello:fancy', array( - 'name' => $name, - 'color' => 'green', - )); + $response = $httpKernel->forward( + 'AcmeHelloBundle:Hello:fancy', array( + 'name' => $name, + 'color' => 'green', + ) + ); .. index:: single: Controller; Rendering templates @@ -490,14 +492,20 @@ that's responsible for generating the HTML (or other format) for the controller. The ``renderView()`` method renders a template and returns its content. The content from the template can be used to create a ``Response`` object:: - $content = $this->renderView('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name)); + $content = $this->renderView( + 'AcmeHelloBundle:Hello:index.html.twig', + array('name' => $name) + ); return new Response($content); This can even be done in just one step with the ``render()`` method, which returns a ``Response`` object containing the content from the template:: - return $this->render('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name)); + return $this->render( + 'AcmeHelloBundle:Hello:index.html.twig', + array('name' => $name) + ); In both cases, the ``Resources/views/Hello/index.html.twig`` template inside the ``AcmeHelloBundle`` will be rendered. @@ -517,7 +525,10 @@ The Symfony templating engine is explained in great detail in the service. The ``templating`` service can also be used directly:: $templating = $this->get('templating'); - $content = $templating->render('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name)); + $content = $templating->render( + 'AcmeHelloBundle:Hello:index.html.twig', + array('name' => $name) + ); .. note:: @@ -525,7 +536,10 @@ The Symfony templating engine is explained in great detail in the be careful to avoid the pitfall of making your directory structure unduly elaborate:: - $templating->render('AcmeHelloBundle:Hello/Greetings:index.html.twig', array('name' => $name)); + $templating->render( + 'AcmeHelloBundle:Hello/Greetings:index.html.twig', + array('name' => $name) + ); // index.html.twig found in Resources/views/Hello/Greetings is rendered. .. index:: @@ -642,7 +656,10 @@ For example, imagine you're processing a form submit:: if ($form->isValid()) { // do some sort of processing - $this->get('session')->setFlash('notice', 'Your changes were saved!'); + $this->get('session')->setFlash( + 'notice', + 'Your changes were saved!' + ); return $this->redirect($this->generateUrl(...)); } diff --git a/book/doctrine.rst b/book/doctrine.rst index 8dde967b0ca..60b32770259 100644 --- a/book/doctrine.rst +++ b/book/doctrine.rst @@ -470,7 +470,9 @@ on its ``id`` value:: ->find($id); if (!$product) { - throw $this->createNotFoundException('No product found for id '.$id); + throw $this->createNotFoundException( + 'No product found for id '.$id + ); } // ... do something, like pass the $product object into a template @@ -555,7 +557,9 @@ you have a route that maps a product id to an update action in a controller:: $product = $em->getRepository('AcmeStoreBundle:Product')->find($id); if (!$product) { - throw $this->createNotFoundException('No product found for id '.$id); + throw $this->createNotFoundException( + 'No product found for id '.$id + ); } $product->setName('New product name!'); @@ -1306,7 +1310,8 @@ and ``nullable``. Take a few examples: /** * A string field with length 255 that cannot be null - * (reflecting the default values for the "type", "length" and *nullable* options) + * (reflecting the default values for the "type", "length" + * and *nullable* options) * * @ORM\Column() */ diff --git a/book/forms.rst b/book/forms.rst index 471ac5e551c..2038047b0db 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -1477,7 +1477,9 @@ method to specify the option:: { $collectionConstraint = new Collection(array( 'name' => new MinLength(5), - 'email' => new Email(array('message' => 'Invalid email address')), + 'email' => new Email( + array('message' => 'Invalid email address') + ), )); return array('validation_constraint' => $collectionConstraint); diff --git a/book/from_flat_php_to_symfony2.rst b/book/from_flat_php_to_symfony2.rst index f9ad97ee141..1894a9483a1 100644 --- a/book/from_flat_php_to_symfony2.rst +++ b/book/from_flat_php_to_symfony2.rst @@ -554,7 +554,10 @@ them for you. Here's the same sample application, now built in Symfony2:: ->createQuery('SELECT p FROM AcmeBlogBundle:Post p') ->execute(); - return $this->render('AcmeBlogBundle:Blog:list.html.php', array('posts' => $posts)); + return $this->render( + 'AcmeBlogBundle:Blog:list.html.php', + array('posts' => $posts) + ); } public function showAction($id) @@ -570,7 +573,10 @@ them for you. Here's the same sample application, now built in Symfony2:: throw $this->createNotFoundException(); } - return $this->render('AcmeBlogBundle:Blog:show.html.php', array('post' => $post)); + return $this->render( + 'AcmeBlogBundle:Blog:show.html.php', + array('post' => $post) + ); } } @@ -590,7 +596,10 @@ now quite a bit simpler: