diff --git a/book/translation.rst b/book/translation.rst index fc6ded5690b..6c6ea3da1c2 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -994,7 +994,7 @@ steps: .. _`i18n`: http://en.wikipedia.org/wiki/Internationalization_and_localization .. _`L10n`: http://en.wikipedia.org/wiki/Internationalization_and_localization .. _`strtr function`: http://www.php.net/manual/en/function.strtr.php -.. _`ISO 31-11`: http://en.wikipedia.org/wiki/Interval_%28mathematics%29#The_ISO_notation +.. _`ISO 31-11`: http://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals .. _`Translatable Extension`: https://github.com/l3pp4rd/DoctrineExtensions .. _`ISO3166 Alpha-2`: http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes .. _`ISO639-1`: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes diff --git a/cookbook/doctrine/file_uploads.rst b/cookbook/doctrine/file_uploads.rst index 4124d2153a1..0d6d911349c 100644 --- a/cookbook/doctrine/file_uploads.rst +++ b/cookbook/doctrine/file_uploads.rst @@ -55,23 +55,29 @@ First, create a simple Doctrine Entity class to work with:: public function getAbsolutePath() { - return null === $this->path ? null : $this->getUploadRootDir().'/'.$this->path; + return null === $this->path + ? null + : $this->getUploadRootDir().'/'.$this->path; } public function getWebPath() { - return null === $this->path ? null : $this->getUploadDir().'/'.$this->path; + return null === $this->path + ? null + : $this->getUploadDir().'/'.$this->path; } protected function getUploadRootDir() { - // the absolute directory path where uploaded documents should be saved + // the absolute directory path where uploaded + // documents should be saved return __DIR__.'/../../../../web/'.$this->getUploadDir(); } protected function getUploadDir() { - // get rid of the __DIR__ so it doesn't screw when displaying uploaded doc/image in the view. + // get rid of the __DIR__ so it doesn't screw up + // when displaying uploaded doc/image in the view. return 'uploads/documents'; } } @@ -213,8 +219,12 @@ object, which is what's returned after a ``file`` field is submitted:: // use the original file name here but you should // sanitize it at least to avoid any security issues - // move takes the target directory and then the target filename to move to - $this->file->move($this->getUploadRootDir(), $this->file->getClientOriginalName()); + // move takes the target directory and then the + // target filename to move to + $this->file->move( + $this->getUploadRootDir(), + $this->file->getClientOriginalName() + ); // set the path property to the filename where you've saved the file $this->path = $this->file->getClientOriginalName(); @@ -266,7 +276,8 @@ Next, refactor the ``Document`` class to take advantage of these callbacks:: { if (null !== $this->file) { // do whatever you want to generate a unique name - $this->path = sha1(uniqid(mt_rand(), true)).'.'.$this->file->guessExtension(); + $filename = sha1(uniqid(mt_rand(), true)); + $this->path = $filename.'.'.$this->file->guessExtension(); } } @@ -373,7 +384,10 @@ property, instead of the actual filename:: // you must throw an exception here if the file cannot be moved // so that the entity is not persisted to the database // which the UploadedFile move() method does - $this->file->move($this->getUploadRootDir(), $this->id.'.'.$this->file->guessExtension()); + $this->file->move( + $this->getUploadRootDir(), + $this->id.'.'.$this->file->guessExtension() + ); unset($this->file); } @@ -398,7 +412,9 @@ property, instead of the actual filename:: public function getAbsolutePath() { - return null === $this->path ? null : $this->getUploadRootDir().'/'.$this->id.'.'.$this->path; + return null === $this->path + ? null + : $this->getUploadRootDir().'/'.$this->id.'.'.$this->path; } } diff --git a/cookbook/doctrine/multiple_entity_managers.rst b/cookbook/doctrine/multiple_entity_managers.rst index 31823a93fd1..89c09465a32 100644 --- a/cookbook/doctrine/multiple_entity_managers.rst +++ b/cookbook/doctrine/multiple_entity_managers.rst @@ -64,7 +64,7 @@ two connections, one for each entity manager. .. note:: - When working with multiple connections and entity managers, you should be + When working with multiple connections and entity managers, you should be explicit about which configuration you want. If you *do* omit the name of the connection or entity manager, the default (i.e. ``default``) is used. @@ -98,7 +98,7 @@ the default entity manager (i.e. ``default``) is returned:: // both return the "default" em $em = $this->get('doctrine')->getManager(); $em = $this->get('doctrine')->getManager('default'); - + $customerEm = $this->get('doctrine')->getManager('customer'); } } @@ -115,17 +115,20 @@ The same applies to repository call:: { // Retrieves a repository managed by the "default" em $products = $this->get('doctrine') - ->getRepository('AcmeStoreBundle:Product') - ->findAll(); + ->getRepository('AcmeStoreBundle:Product') + ->findAll() + ; // Explicit way to deal with the "default" em $products = $this->get('doctrine') - ->getRepository('AcmeStoreBundle:Product', 'default') - ->findAll(); + ->getRepository('AcmeStoreBundle:Product', 'default') + ->findAll() + ; // Retrieves a repository managed by the "customer" em $customers = $this->get('doctrine') - ->getRepository('AcmeCustomerBundle:Customer', 'customer') - ->findAll(); + ->getRepository('AcmeCustomerBundle:Customer', 'customer') + ->findAll() + ; } } diff --git a/cookbook/doctrine/registration_form.rst b/cookbook/doctrine/registration_form.rst index 09d6c975352..60144c0ed82 100644 --- a/cookbook/doctrine/registration_form.rst +++ b/cookbook/doctrine/registration_form.rst @@ -194,7 +194,11 @@ Next, create the form for this ``Registration`` model:: public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('user', new UserType()); - $builder->add('terms', 'checkbox', array('property_path' => 'termsAccepted')); + $builder->add( + 'terms', + 'checkbox', + array('property_path' => 'termsAccepted') + ); } public function getName() @@ -227,9 +231,15 @@ controller for displaying the registration form:: { public function registerAction() { - $form = $this->createForm(new RegistrationType(), new Registration()); - - return $this->render('AcmeAccountBundle:Account:register.html.twig', array('form' => $form->createView())); + $form = $this->createForm( + new RegistrationType(), + new Registration() + ); + + return $this->render( + 'AcmeAccountBundle:Account:register.html.twig', + array('form' => $form->createView()) + ); } } @@ -264,7 +274,10 @@ the validation and saves the data into the database:: return $this->redirect(...); } - return $this->render('AcmeAccountBundle:Account:register.html.twig', array('form' => $form->createView())); + return $this->render( + 'AcmeAccountBundle:Account:register.html.twig', + array('form' => $form->createView()) + ); } That's it! Your form now validates, and allows you to save the ``User`` diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index 3ae234c4d54..ec798aefa21 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -96,7 +96,12 @@ Now, suppose you're sending an email to ``recipient@example.com``. ->setSubject('Hello Email') ->setFrom('send@example.com') ->setTo('recipient@example.com') - ->setBody($this->renderView('HelloBundle:Hello:email.txt.twig', array('name' => $name))) + ->setBody( + $this->renderView( + 'HelloBundle:Hello:email.txt.twig', + array('name' => $name) + ) + ) ; $this->get('mailer')->send($message); @@ -150,10 +155,10 @@ you to open the report with details of the sent emails. - setSubject('Hello Email') ->setFrom('send@example.com') ->setTo('recipient@example.com') - ->setBody($this->renderView('HelloBundle:Hello:email.txt.twig', array('name' => $name))) + ->setBody( + $this->renderView( + 'HelloBundle:Hello:email.txt.twig', + array('name' => $name) + ) + ) ; $this->get('mailer')->send($message); diff --git a/cookbook/form/form_collections.rst b/cookbook/form/form_collections.rst index c088912aba5..8c646d7947b 100755 --- a/cookbook/form/form_collections.rst +++ b/cookbook/form/form_collections.rst @@ -607,7 +607,9 @@ the relationship between the removed ``Tag`` and ``Task`` object. $originalTags = array(); // Create an array of the current Tag objects in the database - foreach ($task->getTags() as $tag) $originalTags[] = $tag; + foreach ($task->getTags() as $tag) { + $originalTags[] = $tag; + } $editForm = $this->createForm(new TaskType(), $task); diff --git a/cookbook/testing/doctrine.rst b/cookbook/testing/doctrine.rst index 239ee3e8cdb..ef9467861a3 100644 --- a/cookbook/testing/doctrine.rst +++ b/cookbook/testing/doctrine.rst @@ -39,7 +39,10 @@ which makes all of this quite easy:: { static::$kernel = static::createKernel(); static::$kernel->boot(); - $this->em = static::$kernel->getContainer()->get('doctrine')->getManager(); + $this->em = static::$kernel->getContainer() + ->get('doctrine') + ->getManager() + ; } public function testSearchByCategoryName() diff --git a/cookbook/testing/profiling.rst b/cookbook/testing/profiling.rst index 8a8055bf278..59b67c9977f 100644 --- a/cookbook/testing/profiling.rst +++ b/cookbook/testing/profiling.rst @@ -27,10 +27,16 @@ environment):: // Check that the profiler is enabled if ($profile = $client->getProfile()) { // check the number of requests - $this->assertLessThan(10, $profile->getCollector('db')->getQueryCount()); + $this->assertLessThan( + 10, + $profile->getCollector('db')->getQueryCount() + ); // check the time spent in the framework - $this->assertLessThan(500, $profile->getCollector('time')->getTotalTime()); + $this->assertLessThan( + 500, + $profile->getCollector('time')->getTotalTime() + ); } } } @@ -42,7 +48,10 @@ finish. It's easy to achieve if you embed the token in the error message:: $this->assertLessThan( 30, $profile->get('db')->getQueryCount(), - sprintf('Checks that query count is less than 30 (token %s)', $profile->getToken()) + sprintf( + 'Checks that query count is less than 30 (token %s)', + $profile->getToken() + ) ); .. caution::