diff --git a/book/controller.rst b/book/controller.rst index 03a03df640f..82189588bf8 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -94,8 +94,8 @@ a controller object. Controllers are also called *actions*. :linenos: // src/Acme/HelloBundle/Controller/HelloController.php - namespace Acme\HelloBundle\Controller; + use Symfony\Component\HttpFoundation\Response; class HelloController @@ -208,8 +208,8 @@ passed to that method: getManager() @@ -1067,7 +1067,7 @@ following method to the ``ProductRepository`` class:: JOIN p.category c WHERE p.id = :id' )->setParameter('id', $id); - + try { return $query->getSingleResult(); } catch (\Doctrine\ORM\NoResultException $e) { diff --git a/book/forms.rst b/book/forms.rst index b7c3750370e..3332886207b 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -798,7 +798,6 @@ that will house the logic for building the task form: .. code-block:: php // src/Acme/TaskBundle/Form/Type/TaskType.php - namespace Acme\TaskBundle\Form\Type; use Symfony\Component\Form\AbstractType; diff --git a/book/from_flat_php_to_symfony2.rst b/book/from_flat_php_to_symfony2.rst index 2d7c9bf8b5f..0ce43d2619d 100644 --- a/book/from_flat_php_to_symfony2.rst +++ b/book/from_flat_php_to_symfony2.rst @@ -543,8 +543,8 @@ them for you. Here's the same sample application, now built in Symfony2: getEntity(); $entityManager = $args->getEntityManager(); - + // perhaps you only want to act on some "Product" entity if ($entity instanceof Product) { // do something with the Product diff --git a/cookbook/form/create_custom_field_type.rst b/cookbook/form/create_custom_field_type.rst index 21ddf251523..6088d786133 100644 --- a/cookbook/form/create_custom_field_type.rst +++ b/cookbook/form/create_custom_field_type.rst @@ -20,7 +20,7 @@ will be called `GenderType` and the file will be stored in the default location for form fields, which is ``\Form\Type``. Make sure the field extends :class:`Symfony\\Component\\Form\\AbstractType`:: - # src/Acme/DemoBundle/Form/Type/GenderType.php + // src/Acme/DemoBundle/Form/Type/GenderType.php namespace Acme\DemoBundle\Form\Type; use Symfony\Component\Form\AbstractType; @@ -153,7 +153,7 @@ new instance of the type in one of your forms:: use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; - + class AuthorType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) @@ -231,7 +231,7 @@ returned by the ``getName`` method defined earlier. We'll see the importance of this in a moment when we use the custom field type. But first, add a ``__construct`` argument to ``GenderType``, which receives the gender configuration:: - # src/Acme/DemoBundle/Form/Type/GenderType.php + // src/Acme/DemoBundle/Form/Type/GenderType.php namespace Acme\DemoBundle\Form\Type; use Symfony\Component\OptionsResolver\OptionsResolverInterface; diff --git a/cookbook/form/data_transformers.rst b/cookbook/form/data_transformers.rst index 051ef417d1d..3226464d5d8 100644 --- a/cookbook/form/data_transformers.rst +++ b/cookbook/form/data_transformers.rst @@ -29,7 +29,6 @@ was entered:: use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; - use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Acme\TaskBundle\Form\DataTransformer\IssueToNumberTransformer; use Doctrine\Common\Persistence\ObjectManager; @@ -96,7 +95,6 @@ was entered:: Next, we create the data transformer, which does the actual conversion:: // src/Acme/TaskBundle/Form/DataTransformer/IssueToNumberTransformer.php - namespace Acme\TaskBundle\Form\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; @@ -188,7 +186,6 @@ manager can be automatically injected: You can now add the type to your form by its alias as follows:: // src/Acme/TaskBundle/Form/Type/TaskType.php - namespace Acme\TaskBundle\Form\Type; use Symfony\Component\Form\AbstractType; diff --git a/cookbook/form/dynamic_form_generation.rst b/cookbook/form/dynamic_form_generation.rst index 7461e106869..3e0720b9585 100644 --- a/cookbook/form/dynamic_form_generation.rst +++ b/cookbook/form/dynamic_form_generation.rst @@ -99,12 +99,12 @@ might look like the following:: class AddNameFieldSubscriber implements EventSubscriberInterface { private $factory; - + public function __construct(FormFactoryInterface $factory) { $this->factory = $factory; } - + public static function getSubscribedEvents() { // Tells the dispatcher that we want to listen on the form.pre_set_data @@ -116,11 +116,11 @@ might look like the following:: { $data = $event->getData(); $form = $event->getForm(); - - // During form creation setData() is called with null as an argument - // by the FormBuilder constructor. We're only concerned with when + + // During form creation setData() is called with null as an argument + // by the FormBuilder constructor. We're only concerned with when // setData is called with an actual Entity object in it (whether new, - // or fetched with Doctrine). This if statement let's us skip right + // or fetched with Doctrine). This if statement let's us skip right // over the null condition. if (null === $data) { return; diff --git a/cookbook/form/form_collections.rst b/cookbook/form/form_collections.rst index 9934ecdb231..f33ba6705d4 100755 --- a/cookbook/form/form_collections.rst +++ b/cookbook/form/form_collections.rst @@ -24,7 +24,7 @@ objects. Start by creating a simple ``Task`` class:: // src/Acme/TaskBundle/Entity/Task.php namespace Acme\TaskBundle\Entity; - + use Doctrine\Common\Collections\ArrayCollection; class Task @@ -37,7 +37,7 @@ objects. Start by creating a simple ``Task`` class:: { $this->tags = new ArrayCollection(); } - + public function getDescription() { return $this->description; @@ -151,19 +151,19 @@ In your controller, you'll now initialize a new instance of ``TaskType``:: // src/Acme/TaskBundle/Controller/TaskController.php namespace Acme\TaskBundle\Controller; - + use Acme\TaskBundle\Entity\Task; use Acme\TaskBundle\Entity\Tag; use Acme\TaskBundle\Form\Type\TaskType; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; - + class TaskController extends Controller { public function newAction(Request $request) { $task = new Task(); - + // dummy code - this is here just so that the Task has some tags // otherwise, this isn't an interesting example $tag1 = new Tag(); @@ -173,9 +173,9 @@ In your controller, you'll now initialize a new instance of ``TaskType``:: $tag2->name = 'tag2'; $task->getTags()->add($tag2); // end dummy code - + $form = $this->createForm(new TaskType(), $task); - + // process the form on POST if ('POST' === $request->getMethod()) { $form->bindRequest($request); @@ -183,7 +183,7 @@ In your controller, you'll now initialize a new instance of ``TaskType``:: // maybe do some form processing, like saving the Task and Tag objects } } - + return $this->render('AcmeTaskBundle:Task:new.html.twig', array( 'form' => $form->createView(), )); @@ -282,7 +282,7 @@ add the ``allow_add`` option to our collection field:: // src/Acme/TaskBundle/Form/Type/TaskType.php // ... - + use Symfony\Component\Form\FormBuilderInterface; public function buildForm(FormBuilderInterface $builder, array $options) @@ -499,7 +499,7 @@ Start by adding the ``allow_delete`` option in the form Type:: // src/Acme/TaskBundle/Form/Type/TaskType.php // ... use Symfony\Component\Form\FormBuilderInterface; - + public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('description'); diff --git a/cookbook/form/use_virtuals_forms.rst b/cookbook/form/use_virtuals_forms.rst index afc348ebb65..8759e517c6c 100644 --- a/cookbook/form/use_virtuals_forms.rst +++ b/cookbook/form/use_virtuals_forms.rst @@ -25,7 +25,7 @@ For example, imagine you have two entities, a ``Company`` and a ``Customer``:: .. code-block:: php - // src/Acme/HelloBundle/Entity/Company.php + // src/Acme/HelloBundle/Entity/Customer.php namespace Acme\HelloBundle\Entity; class Customer diff --git a/cookbook/security/custom_authentication_provider.rst b/cookbook/security/custom_authentication_provider.rst index bdbc1220bf6..dce5426000c 100644 --- a/cookbook/security/custom_authentication_provider.rst +++ b/cookbook/security/custom_authentication_provider.rst @@ -61,11 +61,11 @@ provider. public $created; public $digest; public $nonce; - + public function __construct(array $roles = array()) { parent::__construct($roles); - + // If the user has roles, consider it authenticated $this->setAuthenticated(count($roles) > 0); } @@ -141,7 +141,7 @@ set an authenticated token in the security context if successful. if ($returnValue instanceof TokenInterface) { return $this->securityContext->setToken($returnValue); - } else if ($returnValue instanceof Response) { + } elseif ($returnValue instanceof Response) { return $event->setResponse($returnValue); } } catch (AuthenticationException $e) { @@ -208,7 +208,7 @@ the ``PasswordDigest`` header value matches with the user's password. { $user = $this->userProvider->loadUserByUsername($token->getUsername()); - if ($user && $this->validateDigest($token->digest, $token->nonce, $token->created, $user->getPassword())) { + if ($user && $this->validateDigest($token->digest, $token->nonce, $token->created, $user->getPassword())) { $authenticatedToken = new WsseUserToken($user->getRoles()); $authenticatedToken->setUser($user); diff --git a/cookbook/security/custom_provider.rst b/cookbook/security/custom_provider.rst index 3f9753d939f..dcccf96bea4 100644 --- a/cookbook/security/custom_provider.rst +++ b/cookbook/security/custom_provider.rst @@ -27,7 +27,7 @@ class: ``getRoles()``, ``getPassword()``, ``getSalt()``, ``getUsername()``, Let's see this in action:: - // src/Acme/WebserviceUserBundle/Security/User.php + // src/Acme/WebserviceUserBundle/Security/User/WebserviceUser.php namespace Acme\WebserviceUserBundle\Security\User; use Symfony\Component\Security\Core\User\UserInterface; @@ -65,7 +65,7 @@ Let's see this in action:: public function getUsername() { return $this->username; - } + } public function eraseCredentials() { @@ -262,4 +262,4 @@ options, the password may be encoded multiple times and encoded to base64. encode_as_base64: false iterations: 1 -.. _MessageDigestPasswordEncoder: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Core/Encoder/MessageDigestPasswordEncoder.php \ No newline at end of file +.. _MessageDigestPasswordEncoder: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Core/Encoder/MessageDigestPasswordEncoder.php diff --git a/cookbook/security/entity_provider.rst b/cookbook/security/entity_provider.rst index e53ad15a23d..c290c736199 100644 --- a/cookbook/security/entity_provider.rst +++ b/cookbook/security/entity_provider.rst @@ -43,7 +43,6 @@ focus on the most important methods that come from the .. code-block:: php // src/Acme/UserBundle/Entity/User.php - namespace Acme\UserBundle\Entity; use Doctrine\ORM\Mapping as ORM; @@ -158,11 +157,8 @@ For more details on each of these, see :class:`Symfony\\Component\\Security\\Cor .. code-block:: php // src/Acme/UserBundle/Entity/User.php - namespace Acme\UserBundle\Entity; - use Symfony\Component\Security\Core\User\EquatableInterface; - // ... public function isEqualTo(UserInterface $user) @@ -275,7 +271,6 @@ For this example, the first three methods will return ``true`` whereas the .. code-block:: php // src/Acme/UserBundle/Entity/User.php - namespace Acme\Bundle\UserBundle\Entity; // ... @@ -333,7 +328,6 @@ The code below shows the implementation of the ``UserRepository`` class:: // src/Acme/UserBundle/Entity/UserRepository.php - namespace Acme\UserBundle\Entity; use Symfony\Component\Security\Core\User\UserInterface; @@ -429,7 +423,6 @@ more users. As a group is also a role, the previous ``getRoles()`` method now returns the list of related groups:: // src/Acme/UserBundle/Entity/User.php - namespace Acme\Bundle\UserBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; @@ -519,7 +512,6 @@ relationship in the ``UserRepository::loadUserByUsername()`` method. This will fetch the user and his associated roles / groups with a single query:: // src/Acme/UserBundle/Entity/UserRepository.php - namespace Acme\Bundle\UserBundle\Entity; // ... diff --git a/cookbook/service_container/event_listener.rst b/cookbook/service_container/event_listener.rst index 6d63f68d7d9..fe200dc3a89 100644 --- a/cookbook/service_container/event_listener.rst +++ b/cookbook/service_container/event_listener.rst @@ -26,11 +26,11 @@ event is just one of the core kernel events:: // We get the exception object from the received event $exception = $event->getException(); $message = 'My Error says: ' . $exception->getMessage(); - + // Customize our response object to display our exception details $response->setContent($message); $response->setStatusCode($exception->getStatusCode()); - + // Send our modified response object to the event $event->setResponse($response); } diff --git a/cookbook/templating/twig_extension.rst b/cookbook/templating/twig_extension.rst index 5addd8f8f6e..3175d828e0c 100644 --- a/cookbook/templating/twig_extension.rst +++ b/cookbook/templating/twig_extension.rst @@ -24,12 +24,10 @@ To get your custom functionality you must first create a Twig Extension class. As an example we will create a price filter to format a given number into price:: // src/Acme/DemoBundle/Twig/AcmeExtension.php - namespace Acme\DemoBundle\Twig; use Twig_Extension; use Twig_Filter_Method; - use Twig_Function_Method; class AcmeExtension extends Twig_Extension { @@ -39,7 +37,7 @@ As an example we will create a price filter to format a given number into price: 'price' => new Twig_Filter_Method($this, 'priceFilter'), ); } - + public function priceFilter($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',') { $price = number_format($number, $decimals, $decPoint, $thousandsSep); @@ -53,7 +51,7 @@ As an example we will create a price filter to format a given number into price: return 'acme_extension'; } } - + .. tip:: Along with custom filters, you can also add custom `functions` and register `global variables`. diff --git a/cookbook/testing/doctrine.rst b/cookbook/testing/doctrine.rst index b8ea7f59d4b..a321e821199 100644 --- a/cookbook/testing/doctrine.rst +++ b/cookbook/testing/doctrine.rst @@ -21,7 +21,6 @@ to get a valid connection. In this case, you'll extend the ``WebTestCase``, which makes all of this quite easy:: // src/Acme/StoreBundle/Tests/Entity/ProductRepositoryFunctionalTest.php - namespace Acme\StoreBundle\Tests\Entity; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;