From 77233fb4a824ec723070f993ada0a3189dd65776 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 14 Dec 2015 11:58:21 +0100 Subject: [PATCH 1/3] Fixed formatting issues --- book/controller.rst | 2 +- cookbook/controller/service.rst | 3 +- cookbook/security/custom_provider.rst | 4 +- cookbook/upgrade/_update_dep_errors.rst.inc | 2 + reference/constraints/Callback.rst | 208 ++++++++++---------- 5 files changed, 110 insertions(+), 109 deletions(-) diff --git a/book/controller.rst b/book/controller.rst index 7ee61edc97f..d61691a368d 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -638,7 +638,7 @@ and then redirects. The message key (``notice`` in this example) can be anything you'll use this key to retrieve the message. In the template of the next page (or even better, in your base layout template), -read any flash messages from the session:: +read any flash messages from the session: .. configuration-block:: diff --git a/cookbook/controller/service.rst b/cookbook/controller/service.rst index f5daf236790..a292292e2f9 100644 --- a/cookbook/controller/service.rst +++ b/cookbook/controller/service.rst @@ -277,8 +277,7 @@ controller: in the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface`. :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getDoctrine` (service: ``doctrine``) - - *Simply inject doctrine instead of fetching it from the container* + Simply inject doctrine instead of fetching it from the container. :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getUser` (service: ``security.context``) .. code-block:: php diff --git a/cookbook/security/custom_provider.rst b/cookbook/security/custom_provider.rst index 60a53517bbe..9531f46b24e 100644 --- a/cookbook/security/custom_provider.rst +++ b/cookbook/security/custom_provider.rst @@ -324,9 +324,9 @@ options, the password may be encoded multiple times and encoded to base64. before comparing it to your encoded password. If ``getSalt()`` returns nothing, then the submitted password is simply encoded using the algorithm you specify in ``security.yml``. If a salt *is* specified, then the following - value is created and *then* hashed via the algorithm: + value is created and *then* hashed via the algorithm:: - ``$password.'{'.$salt.'}';`` + $password.'{'.$salt.'}' If your external users have their passwords salted via a different method, then you'll need to do a bit more work so that Symfony properly encodes diff --git a/cookbook/upgrade/_update_dep_errors.rst.inc b/cookbook/upgrade/_update_dep_errors.rst.inc index 663c0091f58..7601a9b9eac 100644 --- a/cookbook/upgrade/_update_dep_errors.rst.inc +++ b/cookbook/upgrade/_update_dep_errors.rst.inc @@ -4,6 +4,8 @@ Dependency Errors If you get a dependency error, it may simply mean that you need to upgrade other Symfony dependencies too. In that case, try the following command: +.. code-block:: bash + $ composer update symfony/symfony --with-dependencies This updates ``symfony/symfony`` and *all* packages that it depends on, which will diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index a2bed55491b..c00b6f4d2c6 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -134,110 +134,110 @@ process. Each method can be one of the following formats: 1) **String method name** - If the name of a method is a simple string (e.g. ``isAuthorValid``), - that method will be called on the same object that's being validated - and the ``ExecutionContextInterface`` will be the only argument (see - the above example). + If the name of a method is a simple string (e.g. ``isAuthorValid``), + that method will be called on the same object that's being validated + and the ``ExecutionContextInterface`` will be the only argument (see + the above example). 2) **Static array callback** - Each method can also be specified as a standard array callback: - - .. configuration-block:: - - .. code-block:: php-annotations - - // src/AppBundle/Entity/Author.php - use Symfony\Component\Validator\Constraints as Assert; - - /** - * @Assert\Callback(methods={ - * { "AppBundle\MyStaticValidatorClass", "isAuthorValid" } - * }) - */ - class Author - { - } - - .. code-block:: yaml - - # src/AppBundle/Resources/config/validation.yml - AppBundle\Entity\Author: - constraints: - - Callback: - methods: - - [AppBundle\MyStaticValidatorClass, isAuthorValid] - - .. code-block:: xml - - - - - - - - - - - - - .. code-block:: php - - // src/AppBundle/Entity/Author.php - - use Symfony\Component\Validator\Mapping\ClassMetadata; - use Symfony\Component\Validator\Constraints\Callback; - - class Author - { - public $name; - - public static function loadValidatorMetadata(ClassMetadata $metadata) - { - $metadata->addConstraint(new Callback(array( - 'methods' => array( - array( - 'AppBundle\MyStaticValidatorClass', - 'isAuthorValid', - ), - ), - ))); - } - } - - In this case, the static method ``isAuthorValid`` will be called on - the ``AppBundle\MyStaticValidatorClass`` class. It's passed both - the original object being validated (e.g. ``Author``) as well as the - ``ExecutionContextInterface``:: - - namespace AppBundle; - - use Symfony\Component\Validator\ExecutionContextInterface; - use AppBundle\Entity\Author; - - class MyStaticValidatorClass - { - public static function isAuthorValid( - Author $author, - ExecutionContextInterface $context - ) { - // ... - } - } - - .. tip:: - - If you specify your ``Callback`` constraint via PHP, then you also - have the option to make your callback either a PHP closure or a - non-static callback. It is *not* currently possible, however, to - specify a :term:`service` as a constraint. To validate using a service, - you should :doc:`create a custom validation constraint - ` and add that new constraint - to your class. + Each method can also be specified as a standard array callback: + + .. configuration-block:: + + .. code-block:: php-annotations + + // src/AppBundle/Entity/Author.php + use Symfony\Component\Validator\Constraints as Assert; + + /** + * @Assert\Callback(methods={ + * { "AppBundle\MyStaticValidatorClass", "isAuthorValid" } + * }) + */ + class Author + { + } + + .. code-block:: yaml + + # src/AppBundle/Resources/config/validation.yml + AppBundle\Entity\Author: + constraints: + - Callback: + methods: + - [AppBundle\MyStaticValidatorClass, isAuthorValid] + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // src/AppBundle/Entity/Author.php + + use Symfony\Component\Validator\Mapping\ClassMetadata; + use Symfony\Component\Validator\Constraints\Callback; + + class Author + { + public $name; + + public static function loadValidatorMetadata(ClassMetadata $metadata) + { + $metadata->addConstraint(new Callback(array( + 'methods' => array( + array( + 'AppBundle\MyStaticValidatorClass', + 'isAuthorValid', + ), + ), + ))); + } + } + + In this case, the static method ``isAuthorValid`` will be called on + the ``AppBundle\MyStaticValidatorClass`` class. It's passed both + the original object being validated (e.g. ``Author``) as well as the + ``ExecutionContextInterface``:: + + namespace AppBundle; + + use Symfony\Component\Validator\ExecutionContextInterface; + use AppBundle\Entity\Author; + + class MyStaticValidatorClass + { + public static function isAuthorValid( + Author $author, + ExecutionContextInterface $context + ) { + // ... + } + } + + .. tip:: + + If you specify your ``Callback`` constraint via PHP, then you also + have the option to make your callback either a PHP closure or a + non-static callback. It is *not* currently possible, however, to + specify a :term:`service` as a constraint. To validate using a service, + you should :doc:`create a custom validation constraint + ` and add that new constraint + to your class. From 81e7f473da67d66e1887302b88094d99ae9e3ca7 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 15 Dec 2015 12:58:15 +0100 Subject: [PATCH 2/3] Restored an italic text --- cookbook/controller/service.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/controller/service.rst b/cookbook/controller/service.rst index a292292e2f9..d4bb24c68d5 100644 --- a/cookbook/controller/service.rst +++ b/cookbook/controller/service.rst @@ -277,7 +277,7 @@ controller: in the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface`. :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getDoctrine` (service: ``doctrine``) - Simply inject doctrine instead of fetching it from the container. + *Simply inject doctrine instead of fetching it from the container.* :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getUser` (service: ``security.context``) .. code-block:: php From c1846f280484340c6c3384c3b2bc899e7355cfe7 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 15 Dec 2015 13:03:11 +0100 Subject: [PATCH 3/3] Improvements --- reference/constraints/Callback.rst | 209 ++++++++++++++--------------- 1 file changed, 104 insertions(+), 105 deletions(-) diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index c00b6f4d2c6..7a58c65062f 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -132,112 +132,111 @@ methods This is an array of the methods that should be executed during the validation process. Each method can be one of the following formats: -1) **String method name** +1) String method name +..................... - If the name of a method is a simple string (e.g. ``isAuthorValid``), - that method will be called on the same object that's being validated - and the ``ExecutionContextInterface`` will be the only argument (see - the above example). +If the name of a method is a simple string (e.g. ``isAuthorValid``), that method +will be called on the same object that's being validated and the +``ExecutionContextInterface`` will be the only argument (see the above example). 2) **Static array callback** +............................ - Each method can also be specified as a standard array callback: - - .. configuration-block:: - - .. code-block:: php-annotations - - // src/AppBundle/Entity/Author.php - use Symfony\Component\Validator\Constraints as Assert; - - /** - * @Assert\Callback(methods={ - * { "AppBundle\MyStaticValidatorClass", "isAuthorValid" } - * }) - */ - class Author - { - } - - .. code-block:: yaml - - # src/AppBundle/Resources/config/validation.yml - AppBundle\Entity\Author: - constraints: - - Callback: - methods: - - [AppBundle\MyStaticValidatorClass, isAuthorValid] - - .. code-block:: xml - - - - - - - - - - - - - .. code-block:: php - - // src/AppBundle/Entity/Author.php - - use Symfony\Component\Validator\Mapping\ClassMetadata; - use Symfony\Component\Validator\Constraints\Callback; - - class Author - { - public $name; - - public static function loadValidatorMetadata(ClassMetadata $metadata) - { - $metadata->addConstraint(new Callback(array( - 'methods' => array( - array( - 'AppBundle\MyStaticValidatorClass', - 'isAuthorValid', - ), - ), - ))); - } - } - - In this case, the static method ``isAuthorValid`` will be called on - the ``AppBundle\MyStaticValidatorClass`` class. It's passed both - the original object being validated (e.g. ``Author``) as well as the - ``ExecutionContextInterface``:: - - namespace AppBundle; - - use Symfony\Component\Validator\ExecutionContextInterface; - use AppBundle\Entity\Author; - - class MyStaticValidatorClass - { - public static function isAuthorValid( - Author $author, - ExecutionContextInterface $context - ) { - // ... - } - } - - .. tip:: - - If you specify your ``Callback`` constraint via PHP, then you also - have the option to make your callback either a PHP closure or a - non-static callback. It is *not* currently possible, however, to - specify a :term:`service` as a constraint. To validate using a service, - you should :doc:`create a custom validation constraint - ` and add that new constraint - to your class. +Each method can also be specified as a standard array callback: + +.. configuration-block:: + + .. code-block:: php-annotations + + // src/AppBundle/Entity/Author.php + use Symfony\Component\Validator\Constraints as Assert; + + /** + * @Assert\Callback(methods={ + * { "AppBundle\MyStaticValidatorClass", "isAuthorValid" } + * }) + */ + class Author + { + } + + .. code-block:: yaml + + # src/AppBundle/Resources/config/validation.yml + AppBundle\Entity\Author: + constraints: + - Callback: + methods: + - [AppBundle\MyStaticValidatorClass, isAuthorValid] + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // src/AppBundle/Entity/Author.php + + use Symfony\Component\Validator\Mapping\ClassMetadata; + use Symfony\Component\Validator\Constraints\Callback; + + class Author + { + public $name; + + public static function loadValidatorMetadata(ClassMetadata $metadata) + { + $metadata->addConstraint(new Callback(array( + 'methods' => array( + array( + 'AppBundle\MyStaticValidatorClass', + 'isAuthorValid', + ), + ), + ))); + } + } + +In this case, the static method ``isAuthorValid`` will be called on the +``AppBundle\MyStaticValidatorClass`` class. It's passed both the original object +being validated (e.g. ``Author``) as well as the ``ExecutionContextInterface``:: + + namespace AppBundle; + + use Symfony\Component\Validator\ExecutionContextInterface; + use AppBundle\Entity\Author; + + class MyStaticValidatorClass + { + public static function isAuthorValid( + Author $author, + ExecutionContextInterface $context + ) { + // ... + } + } + +.. tip:: + + If you specify your ``Callback`` constraint via PHP, then you also have the + option to make your callback either a PHP closure or a non-static callback. + It is *not* currently possible, however, to specify a :term:`service` as a + constraint. To validate using a service, you should :doc:`create a custom + validation constraint ` and add that + new constraint to your class.