From 81cec5d0fda6754bd78c8603a513a40626774e91 Mon Sep 17 00:00:00 2001 From: giosh94mhz Date: Mon, 18 Aug 2014 18:10:42 +0200 Subject: [PATCH 1/6] Fix documentation for group_sequence_provider --- book/validation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/validation.rst b/book/validation.rst index 7b2cdc5ff82..2f961f8b161 100644 --- a/book/validation.rst +++ b/book/validation.rst @@ -1115,7 +1115,7 @@ provides a sequence of groups to be validated: # src/Acme/DemoBundle/Resources/config/validation.yml Acme\DemoBundle\Entity\User: - group_sequence_provider: ~ + group_sequence_provider: true .. code-block:: php-annotations From 37ab23d0a1413b206434e7bfab6451b0b352446b Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 17 Aug 2014 08:45:09 +0200 Subject: [PATCH 2/6] document multiple recipients in XML configs Adds an example on how to configure multiple recipients in Monolog for sending log entries as e-mails. --- cookbook/logging/monolog_email.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cookbook/logging/monolog_email.rst b/cookbook/logging/monolog_email.rst index 9b6dee43540..a3cc3129bfb 100644 --- a/cookbook/logging/monolog_email.rst +++ b/cookbook/logging/monolog_email.rst @@ -57,10 +57,18 @@ it is broken down. + level="debug"> + + error@example.com + + + + From da441aeb3a175c3508da6de9ad8f9bb2f8458af0 Mon Sep 17 00:00:00 2001 From: Ahmed Siouani Date: Fri, 22 Aug 2014 13:59:12 +0200 Subject: [PATCH 3/6] Fixed minor typos. --- components/translation/introduction.rst | 2 +- reference/forms/types/options/inherit_data.rst.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/translation/introduction.rst b/components/translation/introduction.rst index 963ba671ff3..a927a62bf3d 100644 --- a/components/translation/introduction.rst +++ b/components/translation/introduction.rst @@ -90,7 +90,7 @@ Loader too. The default loaders are: .. versionadded:: 2.1 The ``IcuDatFileLoader``, ``IcuResFileLoader``, ``IniFileLoader``, - ``MofileLoader``, ``PoFileLoader`` and ``QtFileLoader`` were introduced + ``MoFileLoader``, ``PoFileLoader`` and ``QtFileLoader`` were introduced in Symfony 2.1. All file loaders require the :doc:`Config component `. diff --git a/reference/forms/types/options/inherit_data.rst.inc b/reference/forms/types/options/inherit_data.rst.inc index 3b789db9f25..9f5f1510ca8 100644 --- a/reference/forms/types/options/inherit_data.rst.inc +++ b/reference/forms/types/options/inherit_data.rst.inc @@ -8,5 +8,5 @@ inherit_data **type**: ``boolean`` **default**: ``false`` This option determines if the form will inherit data from its parent form. -This can be useful is you have a set of fields that are duplicated across +This can be useful if you have a set of fields that are duplicated across multiple forms. See :doc:`/cookbook/form/inherit_data_option`. From fb98977febb45de8f9587899b4bafa4aae194231 Mon Sep 17 00:00:00 2001 From: Ronan Guilloux Date: Wed, 20 Aug 2014 16:19:44 +0200 Subject: [PATCH 4/6] Adding 'attr' option to the Textarea options list `attr` is a quite useful option, but not yet listed here. BTW, the `attr.rst.inc` file already includes an `attr` conf. example concerning textareas. --- reference/forms/types/textarea.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reference/forms/types/textarea.rst b/reference/forms/types/textarea.rst index c3bca0a8c60..1352d9e2e6f 100644 --- a/reference/forms/types/textarea.rst +++ b/reference/forms/types/textarea.rst @@ -9,8 +9,9 @@ Renders a ``textarea`` HTML element. +-------------+------------------------------------------------------------------------+ | Rendered as | ``textarea`` tag | +-------------+------------------------------------------------------------------------+ -| Inherited | - `data`_ | -| options | - `disabled`_ | +| Inherited | - `attr`_ | +| options | - `data`_ | +| | - `disabled`_ | | | - `empty_data`_ | | | - `error_bubbling`_ | | | - `error_mapping`_ | @@ -32,6 +33,8 @@ Inherited Options These options inherit from the :doc:`form ` type: +.. include:: /reference/forms/types/options/attr.rst.inc + .. include:: /reference/forms/types/options/data.rst.inc .. include:: /reference/forms/types/options/disabled.rst.inc From 01dc25cbc137a7410efffbca19823d0e86a3525c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 21 Aug 2014 23:13:59 +0200 Subject: [PATCH 5/6] [Reference] consistent & complete config examples --- reference/configuration/doctrine.rst | 57 ++-- reference/configuration/framework.rst | 59 +++- reference/configuration/swiftmailer.rst | 52 ++-- reference/constraints/All.rst | 10 +- reference/constraints/Blank.rst | 2 +- reference/constraints/Callback.rst | 12 +- reference/constraints/Collection.rst | 15 +- reference/constraints/Country.rst | 4 +- reference/constraints/Currency.rst | 20 +- reference/constraints/Email.rst | 4 +- reference/constraints/EqualTo.rst | 24 +- reference/constraints/False.rst | 2 +- reference/constraints/File.rst | 1 - reference/constraints/GreaterThan.rst | 22 +- reference/constraints/GreaterThanOrEqual.rst | 22 +- reference/constraints/Iban.rst | 36 ++- reference/constraints/IdenticalTo.rst | 24 +- reference/constraints/Image.rst | 7 +- reference/constraints/Ip.rst | 8 +- reference/constraints/Isbn.rst | 26 +- reference/constraints/Issn.rst | 18 +- reference/constraints/Language.rst | 10 +- reference/constraints/Length.rst | 20 +- reference/constraints/LessThan.rst | 22 +- reference/constraints/LessThanOrEqual.rst | 22 +- reference/constraints/Locale.rst | 10 +- reference/constraints/Luhn.rst | 4 +- reference/constraints/NotBlank.rst | 2 +- reference/constraints/NotEqualTo.rst | 24 +- reference/constraints/NotIdenticalTo.rst | 24 +- reference/constraints/NotNull.rst | 2 +- reference/constraints/Null.rst | 4 +- reference/constraints/Range.rst | 16 +- reference/constraints/Regex.rst | 14 +- reference/constraints/True.rst | 7 +- reference/constraints/Type.rst | 4 +- reference/constraints/UniqueEntity.rst | 4 +- reference/constraints/Url.rst | 10 +- reference/constraints/UserPassword.rst | 10 +- reference/constraints/Valid.rst | 10 +- reference/dic_tags.rst | 306 +++++++++++++++---- 41 files changed, 619 insertions(+), 331 deletions(-) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 40a291a2076..9f52c397983 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -356,32 +356,37 @@ The following block shows all possible configuration keys: .. code-block:: xml - - - - - - bar - string - Acme\HelloBundle\MyCustomType - - + + + + + + + bar + string + Acme\HelloBundle\MyCustomType + + + If you want to configure multiple connections in YAML, put them under the ``connections`` key and give them a unique name: diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index a0e5ba5f555..0f21105a580 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -101,21 +101,26 @@ have installed `PhpStormOpener`_ and use PHPstorm, you will do something like: .. code-block:: yaml + # app/config/config.yml framework: ide: "pstorm://%%f:%%l" .. code-block:: xml - - + + + - .. code-block:: php + // app/config/config.php $container->loadFromExtension('framework', array( 'ide' => 'pstorm://%%f:%%l', )); @@ -155,17 +160,26 @@ see :doc:`/cookbook/request/load_balancer_reverse_proxy`. .. code-block:: yaml + # app/config/config.yml framework: trusted_proxies: [192.0.0.1, 10.0.0.0/8] .. code-block:: xml - - - + + + + + + .. code-block:: php + // app/config/config.php $container->loadFromExtension('framework', array( 'trusted_proxies' => array('192.0.0.1', '10.0.0.0/8'), )); @@ -282,9 +296,17 @@ the value to ``null``: .. code-block:: xml - - - + + + + + + + .. code-block:: php @@ -370,15 +392,24 @@ Now, activate the ``assets_version`` option: .. code-block:: xml - - - + + + + + + twig + + .. code-block:: php // app/config/config.php $container->loadFromExtension('framework', array( - ..., + // ... 'templating' => array( 'engines' => array('twig'), 'assets_version' => 'v2', diff --git a/reference/configuration/swiftmailer.rst b/reference/configuration/swiftmailer.rst index 77304dff4f2..9295493eb68 100644 --- a/reference/configuration/swiftmailer.rst +++ b/reference/configuration/swiftmailer.rst @@ -200,29 +200,35 @@ Full default Configuration .. code-block:: xml - - - - - + + + + + + + + + Using multiple Mailers ---------------------- diff --git a/reference/constraints/All.rst b/reference/constraints/All.rst index 2e45602375d..5f5aa859a3d 100644 --- a/reference/constraints/All.rst +++ b/reference/constraints/All.rst @@ -24,7 +24,7 @@ entry in that array: .. code-block:: yaml - # src/UserBundle/Resources/config/validation.yml + # src/Acme/UserBundle/Resources/config/validation.yml Acme\UserBundle\Entity\User: properties: favoriteColors: @@ -37,15 +37,15 @@ entry in that array: // src/Acme/UserBundle/Entity/User.php namespace Acme\UserBundle\Entity; - + use Symfony\Component\Validator\Constraints as Assert; - + class User { /** * @Assert\All({ * @Assert\NotBlank, - * @Assert\Length(min = "5") + * @Assert\Length(min = 5) * }) */ protected $favoriteColors = array(); @@ -77,7 +77,7 @@ entry in that array: // src/Acme/UserBundle/Entity/User.php namespace Acme\UserBundle\Entity; - + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; diff --git a/reference/constraints/Blank.rst b/reference/constraints/Blank.rst index 85de8f59df0..5679aa5bf56 100644 --- a/reference/constraints/Blank.rst +++ b/reference/constraints/Blank.rst @@ -26,7 +26,7 @@ of an ``Author`` class were blank, you could do the following: .. code-block:: yaml - # src/BlogBundle/Resources/config/validation.yml + # src/Acme/BlogBundle/Resources/config/validation.yml Acme\BlogBundle\Entity\Author: properties: firstName: diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index 59495889506..f6d570962d4 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -98,17 +98,17 @@ those errors should be attributed:: // ... use Symfony\Component\Validator\ExecutionContextInterface; - + class Author { // ... private $firstName; - + public function isAuthorValid(ExecutionContextInterface $context) { // somehow you have an array of "fake names" $fakeNames = array(); - + // check if the name is actually a fake name if (in_array($this->getFirstName(), $fakeNames)) { $context->addViolationAt('firstname', 'This name sounds totally fake!', array(), null); @@ -155,7 +155,7 @@ process. Each method can be one of the following formats: /** * @Assert\Callback(methods={ - * { "Acme\BlogBundle\MyStaticValidatorClass", "isAuthorValid"} + * { "Acme\BlogBundle\MyStaticValidatorClass", "isAuthorValid" } * }) */ class Author @@ -208,10 +208,10 @@ process. Each method can be one of the following formats: object being validated (e.g. ``Author``) as well as the ``ExecutionContextInterface``:: namespace Acme\BlogBundle; - + use Symfony\Component\Validator\ExecutionContextInterface; use Acme\BlogBundle\Entity\Author; - + class MyStaticValidatorClass { public static function isAuthorValid(Author $author, ExecutionContextInterface $context) diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index 0e21d2c8a0d..6f028e358e2 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -85,7 +85,7 @@ blank but is no longer than 100 characters in length, you would do the following * @Assert\NotBlank(), * @Assert\Length( * max = 100, - * maxMessage = "Your bio is too long!" + * maxMessage = "Your short bio is too long!" * ) * } * }, @@ -117,7 +117,7 @@ blank but is no longer than 100 characters in length, you would do the following - + @@ -146,7 +146,10 @@ blank but is no longer than 100 characters in length, you would do the following 'personal_email' => new Assert\Email(), 'lastName' => array( new Assert\NotBlank(), - new Assert\Length(array("max" => 100)), + new Assert\Length(array( + 'max' => 100, + 'maxMessage' => 'Your short bio is too long!', + )), ), ), 'allowMissingFields' => true, @@ -215,13 +218,11 @@ field is optional but must be a valid email if supplied, you can do the followin * @Assert\Collection( * fields={ * "personal_email" = @Assert\Required({@Assert\NotBlank, @Assert\Email}), - * "alternate_email" = @Assert\Optional(@Assert\Email), + * "alternate_email" = @Assert\Optional(@Assert\Email) * } * ) */ - protected $profileData = array( - 'personal_email', - ); + protected $profileData = array('personal_email'); } .. code-block:: xml diff --git a/reference/constraints/Country.rst b/reference/constraints/Country.rst index 86efb4636eb..f6dc5c10446 100644 --- a/reference/constraints/Country.rst +++ b/reference/constraints/Country.rst @@ -20,7 +20,7 @@ Basic Usage .. code-block:: yaml - # src/UserBundle/Resources/config/validation.yml + # src/Acme/UserBundle/Resources/config/validation.yml Acme\UserBundle\Entity\User: properties: country: @@ -36,7 +36,7 @@ Basic Usage class User { /** - * @Assert\Country + * @Assert\Country() */ protected $country; } diff --git a/reference/constraints/Currency.rst b/reference/constraints/Currency.rst index 22709f469ba..553c2be4ec1 100644 --- a/reference/constraints/Currency.rst +++ b/reference/constraints/Currency.rst @@ -26,7 +26,7 @@ currency, you could do the following: .. code-block:: yaml - # src/EcommerceBundle/Resources/config/validation.yml + # src/Acme/EcommerceBundle/Resources/config/validation.yml Acme\EcommerceBundle\Entity\Order: properties: currency: @@ -50,11 +50,17 @@ currency, you could do the following: .. code-block:: xml - - - - - + + + + + + + + + .. code-block:: php @@ -82,4 +88,4 @@ message This is the message that will be shown if the value is not a valid currency. -.. _`3-letter ISO 4217`: http://en.wikipedia.org/wiki/ISO_4217 +.. _`3-letter ISO 4217`: http://en.wikipedia.org/wiki/ISO_4217 diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index 5eacfbda04b..85e15ec85d6 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -23,7 +23,7 @@ Basic Usage .. code-block:: yaml - # src/BlogBundle/Resources/config/validation.yml + # src/Acme/BlogBundle/Resources/config/validation.yml Acme\BlogBundle\Entity\Author: properties: email: @@ -71,7 +71,7 @@ Basic Usage // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; diff --git a/reference/constraints/EqualTo.rst b/reference/constraints/EqualTo.rst index 1079bd90430..c57fce55e11 100644 --- a/reference/constraints/EqualTo.rst +++ b/reference/constraints/EqualTo.rst @@ -8,7 +8,7 @@ Validates that a value is equal to another value, defined in the options. To force that a value is *not* equal, see :doc:`/reference/constraints/NotEqualTo`. .. caution:: - + This constraint compares using ``==``, so ``3`` and ``"3"`` are considered equal. Use :doc:`/reference/constraints/IdenticalTo` to compare with ``===``. @@ -34,7 +34,7 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to .. code-block:: yaml - # src/SocialBundle/Resources/config/validation.yml + # src/Acme/SocialBundle/Resources/config/validation.yml Acme\SocialBundle\Entity\Person: properties: age: @@ -61,13 +61,19 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to .. code-block:: xml - - - - - - - + + + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/False.rst b/reference/constraints/False.rst index f379d458ec4..b3d241881e7 100644 --- a/reference/constraints/False.rst +++ b/reference/constraints/False.rst @@ -41,7 +41,7 @@ method returns **false**: .. code-block:: yaml - # src/BlogBundle/Resources/config/validation.yml + # src/Acme/BlogBundle/Resources/config/validation.yml Acme\BlogBundle\Entity\Author getters: stateInvalid: diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 683d0fe6a49..c062199744e 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -78,7 +78,6 @@ below a certain file size and a valid PDF, add the following: maxSize: 1024k mimeTypes: [application/pdf, application/x-pdf] mimeTypesMessage: Please upload a valid PDF - .. code-block:: php-annotations diff --git a/reference/constraints/GreaterThan.rst b/reference/constraints/GreaterThan.rst index 80439900b26..2d773953bcd 100644 --- a/reference/constraints/GreaterThan.rst +++ b/reference/constraints/GreaterThan.rst @@ -30,7 +30,7 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than .. code-block:: yaml - # src/SocialBundle/Resources/config/validation.yml + # src/Acme/SocialBundle/Resources/config/validation.yml Acme\SocialBundle\Entity\Person: properties: age: @@ -57,13 +57,19 @@ If you want to ensure that the ``age`` of a ``Person`` class is greater than .. code-block:: xml - - - - - - - + + + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/GreaterThanOrEqual.rst b/reference/constraints/GreaterThanOrEqual.rst index 0dfe7072dc6..9d4cf37ecc5 100644 --- a/reference/constraints/GreaterThanOrEqual.rst +++ b/reference/constraints/GreaterThanOrEqual.rst @@ -29,7 +29,7 @@ or equal to ``18``, you could do the following: .. code-block:: yaml - # src/SocialBundle/Resources/config/validation.yml + # src/Acme/SocialBundle/Resources/config/validation.yml Acme\SocialBundle\Entity\Person: properties: age: @@ -56,13 +56,19 @@ or equal to ``18``, you could do the following: .. code-block:: xml - - - - - - - + + + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/Iban.rst b/reference/constraints/Iban.rst index a482903ace6..45a423e945c 100644 --- a/reference/constraints/Iban.rst +++ b/reference/constraints/Iban.rst @@ -36,22 +36,11 @@ will contain an International Bank Account Number. - Iban: message: This is not a valid International Bank Account Number (IBAN). - .. code-block:: xml - - - - - - - - - - .. code-block:: php-annotations // src/Acme/SubscriptionBundle/Entity/Transaction.php - namespace Acme\SubscriptionBundle\Entity\Transaction; - + namespace Acme\SubscriptionBundle\Entity; + use Symfony\Component\Validator\Constraints as Assert; class Transaction @@ -62,11 +51,28 @@ will contain an International Bank Account Number. protected $bankAccountNumber; } + .. code-block:: xml + + + + + + + + + + + + + + .. code-block:: php // src/Acme/SubscriptionBundle/Entity/Transaction.php - namespace Acme\SubscriptionBundle\Entity\Transaction; - + namespace Acme\SubscriptionBundle\Entity; + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; diff --git a/reference/constraints/IdenticalTo.rst b/reference/constraints/IdenticalTo.rst index ea010607dd9..068035f31a9 100644 --- a/reference/constraints/IdenticalTo.rst +++ b/reference/constraints/IdenticalTo.rst @@ -9,7 +9,7 @@ To force that a value is *not* identical, see :doc:`/reference/constraints/NotIdenticalTo`. .. caution:: - + This constraint compares using ``===``, so ``3`` and ``"3"`` are *not* considered equal. Use :doc:`/reference/constraints/EqualTo` to compare with ``==``. @@ -35,7 +35,7 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to .. code-block:: yaml - # src/SocialBundle/Resources/config/validation.yml + # src/Acme/SocialBundle/Resources/config/validation.yml Acme\SocialBundle\Entity\Person: properties: age: @@ -62,13 +62,19 @@ If you want to ensure that the ``age`` of a ``Person`` class is equal to .. code-block:: xml - - - - - - - + + + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/Image.rst b/reference/constraints/Image.rst index 7469f45ac96..3ba81f818fc 100644 --- a/reference/constraints/Image.rst +++ b/reference/constraints/Image.rst @@ -77,11 +77,12 @@ it is between a certain size, add the following: maxWidth: 400 minHeight: 200 maxHeight: 400 - .. code-block:: php-annotations // src/Acme/BlogBundle/Entity/Author.php + namespace Acme\BlogBundle\Entity; + use Symfony\Component\Validator\Constraints as Assert; class Author @@ -120,15 +121,13 @@ it is between a certain size, add the following: .. code-block:: php // src/Acme/BlogBundle/Entity/Author.php - // ... + namespace Acme\BlogBundle\Entity; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\Image; class Author { - // ... - public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('headshot', new Image(array( diff --git a/reference/constraints/Ip.rst b/reference/constraints/Ip.rst index 04b85403985..0cea9668340 100644 --- a/reference/constraints/Ip.rst +++ b/reference/constraints/Ip.rst @@ -23,7 +23,7 @@ Basic Usage .. code-block:: yaml - # src/BlogBundle/Resources/config/validation.yml + # src/Acme/BlogBundle/Resources/config/validation.yml Acme\BlogBundle\Entity\Author: properties: ipAddress: @@ -33,7 +33,7 @@ Basic Usage // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Constraints as Assert; class Author @@ -63,10 +63,10 @@ Basic Usage // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; - + class Author { public static function loadValidatorMetadata(ClassMetadata $metadata) diff --git a/reference/constraints/Isbn.rst b/reference/constraints/Isbn.rst index 9518c527042..84cb78b16e5 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -43,6 +43,8 @@ on an object that will contain a ISBN number. .. code-block:: php-annotations // src/Acme/BookcaseBundle/Entity/Book.php + namespace Acme\BookcaseBundle\Entity; + use Symfony\Component\Validator\Constraints as Assert; class Book @@ -60,15 +62,21 @@ on an object that will contain a ISBN number. .. code-block:: xml - - - - - - - - - + + + + + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/Issn.rst b/reference/constraints/Issn.rst index 20836159eca..0c200a73490 100644 --- a/reference/constraints/Issn.rst +++ b/reference/constraints/Issn.rst @@ -25,7 +25,7 @@ Basic Usage .. code-block:: yaml - # src/JournalBundle/Resources/config/validation.yml + # src/Acme/JournalBundle/Resources/config/validation.yml Acme\JournalBundle\Entity\Journal: properties: issn: @@ -49,11 +49,17 @@ Basic Usage .. code-block:: xml - - - - - + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/Language.rst b/reference/constraints/Language.rst index b8a87fbd500..617d554a508 100644 --- a/reference/constraints/Language.rst +++ b/reference/constraints/Language.rst @@ -21,7 +21,7 @@ Basic Usage .. code-block:: yaml - # src/UserBundle/Resources/config/validation.yml + # src/Acme/UserBundle/Resources/config/validation.yml Acme\UserBundle\Entity\User: properties: preferredLanguage: @@ -31,13 +31,13 @@ Basic Usage // src/Acme/UserBundle/Entity/User.php namespace Acme\UserBundle\Entity; - + use Symfony\Component\Validator\Constraints as Assert; - + class User { /** - * @Assert\Language + * @Assert\Language() */ protected $preferredLanguage; } @@ -61,7 +61,7 @@ Basic Usage // src/Acme/UserBundle/Entity/User.php namespace Acme\UserBundle\Entity; - + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index edc065635da..6c1023c15aa 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -35,8 +35,8 @@ To verify that the ``firstName`` field length of a class is between "2" and - Length: min: 2 max: 50 - minMessage: "Your first name must be at least {{ limit }} characters length" - maxMessage: "Your first name cannot be longer than {{ limit }} characters length" + minMessage: "Your first name must be at least {{ limit }} characters long" + maxMessage: "Your first name cannot be longer than {{ limit }} characters long" .. code-block:: php-annotations @@ -49,10 +49,10 @@ To verify that the ``firstName`` field length of a class is between "2" and { /** * @Assert\Length( - * min = "2", - * max = "50", - * minMessage = "Your first name must be at least {{ limit }} characters length", - * maxMessage = "Your first name cannot be longer than {{ limit }} characters length" + * min = 2, + * max = 50, + * minMessage = "Your first name must be at least {{ limit }} characters long", + * maxMessage = "Your first name cannot be longer than {{ limit }} characters long" * ) */ protected $firstName; @@ -71,8 +71,8 @@ To verify that the ``firstName`` field length of a class is between "2" and - - + + @@ -93,8 +93,8 @@ To verify that the ``firstName`` field length of a class is between "2" and $metadata->addPropertyConstraint('firstName', new Assert\Length(array( 'min' => 2, 'max' => 50, - 'minMessage' => 'Your first name must be at least {{ limit }} characters length', - 'maxMessage' => 'Your first name cannot be longer than {{ limit }} characters length', + 'minMessage' => 'Your first name must be at least {{ limit }} characters long', + 'maxMessage' => 'Your first name cannot be longer than {{ limit }} characters long', ))); } } diff --git a/reference/constraints/LessThan.rst b/reference/constraints/LessThan.rst index 849b157bc0a..ea5be3c6675 100644 --- a/reference/constraints/LessThan.rst +++ b/reference/constraints/LessThan.rst @@ -30,7 +30,7 @@ If you want to ensure that the ``age`` of a ``Person`` class is less than .. code-block:: yaml - # src/SocialBundle/Resources/config/validation.yml + # src/Acme/SocialBundle/Resources/config/validation.yml Acme\SocialBundle\Entity\Person: properties: age: @@ -57,13 +57,19 @@ If you want to ensure that the ``age`` of a ``Person`` class is less than .. code-block:: xml - - - - - - - + + + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/LessThanOrEqual.rst b/reference/constraints/LessThanOrEqual.rst index d706ac20693..a936ee76ba8 100644 --- a/reference/constraints/LessThanOrEqual.rst +++ b/reference/constraints/LessThanOrEqual.rst @@ -29,7 +29,7 @@ equal to ``80``, you could do the following: .. code-block:: yaml - # src/SocialBundle/Resources/config/validation.yml + # src/Acme/SocialBundle/Resources/config/validation.yml Acme\SocialBundle\Entity\Person: properties: age: @@ -56,13 +56,19 @@ equal to ``80``, you could do the following: .. code-block:: xml - - - - - - - + + + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index 9bb4f1a35ca..cf411c11ecb 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -24,7 +24,7 @@ Basic Usage .. code-block:: yaml - # src/UserBundle/Resources/config/validation.yml + # src/Acme/UserBundle/Resources/config/validation.yml Acme\UserBundle\Entity\User: properties: locale: @@ -34,13 +34,13 @@ Basic Usage // src/Acme/UserBundle/Entity/User.php namespace Acme\UserBundle\Entity; - + use Symfony\Component\Validator\Constraints as Assert; class User { /** - * @Assert\Locale + * @Assert\Locale() */ protected $locale; } @@ -64,10 +64,10 @@ Basic Usage // src/Acme/UserBundle/Entity/User.php namespace Acme\UserBundle\Entity; - + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; - + class User { public static function loadValidatorMetadata(ClassMetadata $metadata) diff --git a/reference/constraints/Luhn.rst b/reference/constraints/Luhn.rst index cdb55c7f156..97d1d27d743 100644 --- a/reference/constraints/Luhn.rst +++ b/reference/constraints/Luhn.rst @@ -38,7 +38,7 @@ will contain a credit card number. .. code-block:: php-annotations // src/Acme/SubscriptionBundle/Entity/Transaction.php - namespace Acme\SubscriptionBundle\Entity\Transaction; + namespace Acme\SubscriptionBundle\Entity; use Symfony\Component\Validator\Constraints as Assert; @@ -70,7 +70,7 @@ will contain a credit card number. .. code-block:: php // src/Acme/SubscriptionBundle/Entity/Transaction.php - namespace Acme\SubscriptionBundle\Entity\Transaction; + namespace Acme\SubscriptionBundle\Entity; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index 2138b7d4186..8de6034b48c 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -25,7 +25,7 @@ were not blank, you could do the following: .. code-block:: yaml - # src/BlogBundle/Resources/config/validation.yml + # src/Acme/BlogBundle/Resources/config/validation.yml Acme\BlogBundle\Entity\Author: properties: firstName: diff --git a/reference/constraints/NotEqualTo.rst b/reference/constraints/NotEqualTo.rst index 0e2e9f7593d..1ea36a08994 100644 --- a/reference/constraints/NotEqualTo.rst +++ b/reference/constraints/NotEqualTo.rst @@ -9,7 +9,7 @@ options. To force that a value is equal, see :doc:`/reference/constraints/EqualTo`. .. caution:: - + This constraint compares using ``!=``, so ``3`` and ``"3"`` are considered equal. Use :doc:`/reference/constraints/NotIdenticalTo` to compare with ``!==``. @@ -35,7 +35,7 @@ If you want to ensure that the ``age`` of a ``Person`` class is not equal to .. code-block:: yaml - # src/SocialBundle/Resources/config/validation.yml + # src/Acme/SocialBundle/Resources/config/validation.yml Acme\SocialBundle\Entity\Person: properties: age: @@ -62,13 +62,19 @@ If you want to ensure that the ``age`` of a ``Person`` class is not equal to .. code-block:: xml - - - - - - - + + + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/NotIdenticalTo.rst b/reference/constraints/NotIdenticalTo.rst index 9a70d41c571..63e6b0462dd 100644 --- a/reference/constraints/NotIdenticalTo.rst +++ b/reference/constraints/NotIdenticalTo.rst @@ -9,7 +9,7 @@ options. To force that a value is identical, see :doc:`/reference/constraints/IdenticalTo`. .. caution:: - + This constraint compares using ``!==``, so ``3`` and ``"3"`` are considered not equal. Use :doc:`/reference/constraints/NotEqualTo` to compare with ``!=``. @@ -35,7 +35,7 @@ If you want to ensure that the ``age`` of a ``Person`` class is *not* equal to .. code-block:: yaml - # src/SocialBundle/Resources/config/validation.yml + # src/Acme/SocialBundle/Resources/config/validation.yml Acme\SocialBundle\Entity\Person: properties: age: @@ -62,13 +62,19 @@ If you want to ensure that the ``age`` of a ``Person`` class is *not* equal to .. code-block:: xml - - - - - - - + + + + + + + + + + + .. code-block:: php diff --git a/reference/constraints/NotNull.rst b/reference/constraints/NotNull.rst index 7b581a8c3d0..668aa5dfd1b 100644 --- a/reference/constraints/NotNull.rst +++ b/reference/constraints/NotNull.rst @@ -25,7 +25,7 @@ were not strictly equal to ``null``, you would: .. code-block:: yaml - # src/BlogBundle/Resources/config/validation.yml + # src/Acme/BlogBundle/Resources/config/validation.yml Acme\BlogBundle\Entity\Author: properties: firstName: diff --git a/reference/constraints/Null.rst b/reference/constraints/Null.rst index 730b60862c0..38baf3d1929 100644 --- a/reference/constraints/Null.rst +++ b/reference/constraints/Null.rst @@ -35,7 +35,7 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Constraints as Assert; class Author @@ -65,7 +65,7 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index 1c46d7778fa..03781307ff2 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -34,8 +34,8 @@ the following: - Range: min: 120 max: 180 - minMessage: You must be at least 120cm tall to enter - maxMessage: You cannot be taller than 180cm to enter + minMessage: You must be at least {{ limit }}cm tall to enter + maxMessage: You cannot be taller than {{ limit }}cm to enter .. code-block:: php-annotations @@ -50,8 +50,8 @@ the following: * @Assert\Range( * min = 120, * max = 180, - * minMessage = "You must be at least 120cm tall to enter", - * maxMessage = "You cannot be taller than 180cm to enter" + * minMessage = "You must be at least {{ limit }}cm tall to enter", + * maxMessage = "You cannot be taller than {{ limit }}cm to enter" * ) */ protected $height; @@ -70,8 +70,8 @@ the following: - - + + @@ -92,8 +92,8 @@ the following: $metadata->addPropertyConstraint('height', new Assert\Range(array( 'min' => 120, 'max' => 180, - 'minMessage' => 'You must be at least 120cm tall to enter', - 'maxMessage' => 'You cannot be taller than 180cm to enter', + 'minMessage' => 'You must be at least {{ limit }}cm tall to enter', + 'maxMessage' => 'You cannot be taller than {{ limit }}cm to enter', ))); } } diff --git a/reference/constraints/Regex.rst b/reference/constraints/Regex.rst index 3b72fd1564b..61285396682 100644 --- a/reference/constraints/Regex.rst +++ b/reference/constraints/Regex.rst @@ -38,7 +38,7 @@ characters at the beginning of your string: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Constraints as Assert; class Author @@ -70,7 +70,7 @@ characters at the beginning of your string: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; @@ -106,7 +106,7 @@ message: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Constraints as Assert; class Author @@ -189,8 +189,8 @@ pattern. This means that the delimiters are removed (e.g. ``/[a-z]+/`` becomes ` However, there are some other incompatibilities between both patterns which cannot be fixed by the constraint. For instance, the HTML5 ``pattern`` attribute -does not support flags. If you have a pattern like ``/[a-z]+/i`` you need to -specify the HTML5 compatible pattern in the ``htmlPattern`` option: +does not support flags. If you have a pattern like ``/[a-z]+/i``, you need +to specify the HTML5 compatible pattern in the ``htmlPattern`` option: .. configuration-block:: @@ -208,7 +208,7 @@ specify the HTML5 compatible pattern in the ``htmlPattern`` option: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Constraints as Assert; class Author @@ -244,7 +244,7 @@ specify the HTML5 compatible pattern in the ``htmlPattern`` option: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; diff --git a/reference/constraints/True.rst b/reference/constraints/True.rst index b284d3dbb2a..8edef81ad93 100644 --- a/reference/constraints/True.rst +++ b/reference/constraints/True.rst @@ -50,7 +50,8 @@ Then you can constrain this method with ``True``. Acme\BlogBundle\Entity\Author: getters: tokenValid: - - 'True': { message: "The token is invalid." } + - 'True': + message: The token is invalid. .. code-block:: php-annotations @@ -96,11 +97,11 @@ Then you can constrain this method with ``True``. use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints\True; - + class Author { protected $token; - + public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addGetterConstraint('tokenValid', new True(array( diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index 1980b083c38..629ca6a9431 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -23,7 +23,7 @@ Basic Usage .. code-block:: yaml - # src/BlogBundle/Resources/config/validation.yml + # src/Acme/BlogBundle/Resources/config/validation.yml Acme\BlogBundle\Entity\Author: properties: age: @@ -65,7 +65,7 @@ Basic Usage .. code-block:: php - + // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index 3052a77b2b1..98be847645f 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -42,7 +42,7 @@ table: .. code-block:: php-annotations - // Acme/UserBundle/Entity/User.php + // Acme/UserBundle/Entity/Author.php namespace Acme\UserBundle\Entity; use Symfony\Component\Validator\Constraints as Assert; @@ -79,7 +79,6 @@ table: - @@ -104,7 +103,6 @@ table: { $metadata->addConstraint(new UniqueEntity(array( 'fields' => 'email', - 'message' => 'This email already exists.', ))); $metadata->addPropertyConstraint('email', new Assert\Email()); diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index c6f45583a73..42ea1f1da2c 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -21,7 +21,7 @@ Basic Usage .. code-block:: yaml - # src/BlogBundle/Resources/config/validation.yml + # src/Acme/BlogBundle/Resources/config/validation.yml Acme\BlogBundle\Entity\Author: properties: bioUrl: @@ -31,7 +31,7 @@ Basic Usage // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Constraints as Assert; class Author @@ -61,10 +61,10 @@ Basic Usage // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; - + use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; - + class Author { public static function loadValidatorMetadata(ClassMetadata $metadata) @@ -72,7 +72,7 @@ Basic Usage $metadata->addPropertyConstraint('bioUrl', new Assert\Url()); } } - + Options ------- diff --git a/reference/constraints/UserPassword.rst b/reference/constraints/UserPassword.rst index d153c89401f..ee879a0d7c2 100644 --- a/reference/constraints/UserPassword.rst +++ b/reference/constraints/UserPassword.rst @@ -40,7 +40,7 @@ password: .. code-block:: yaml - # src/UserBundle/Resources/config/validation.yml + # src/Acme/UserBundle/Resources/config/validation.yml Acme\UserBundle\Form\Model\ChangePassword: properties: oldPassword: @@ -66,15 +66,17 @@ password: .. code-block:: xml - + - - + + + + diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index 669ae84b32f..407c5339cbc 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -85,7 +85,7 @@ an ``Address`` instance in the ``$address`` property. /** * @Assert\NotBlank - * @Assert\Length(max = "5") + * @Assert\Length(max = 5) */ protected $zipCode; } @@ -93,11 +93,13 @@ an ``Address`` instance in the ``$address`` property. // src/Acme/HelloBundle/Entity/Author.php namespace Acme\HelloBundle\Entity; + use Symfony\Component\Validator\Constraints as Assert; + class Author { /** * @Assert\NotBlank - * @Assert\Length(min = "4") + * @Assert\Length(min = 4) */ protected $firstName; @@ -159,9 +161,7 @@ an ``Address`` instance in the ``$address`` property. { $metadata->addPropertyConstraint('street', new Assert\NotBlank()); $metadata->addPropertyConstraint('zipCode', new Assert\NotBlank()); - $metadata->addPropertyConstraint( - 'zipCode', - new Assert\Length(array("max" => 5))); + $metadata->addPropertyConstraint('zipCode', new Assert\Length(array("max" => 5))); } } diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index d975a79c728..d085f14999f 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -126,9 +126,17 @@ And then register it as a tagged service: .. code-block:: xml - - + + + + + + + + .. code-block:: php @@ -177,9 +185,17 @@ Second, define a service: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php @@ -317,9 +333,20 @@ the ``form.type_extension`` tag: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -389,9 +416,17 @@ Then register this class and tag it with ``kernel.cache_clearer``: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php @@ -452,9 +487,17 @@ To register your warmer with Symfony, give it the ``kernel.cache_warmer`` tag: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php @@ -600,9 +643,20 @@ configuration, and tag it with ``kernel.event_subscriber``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -655,16 +709,24 @@ channel when injecting the logger in a service. .. code-block:: xml - - - - + + + + + + + + + + .. code-block:: php $definition = new Definition('Fully\Qualified\Loader\Class\Name', array(new Reference('logger')); $definition->addTag('monolog.logger', array('channel' => 'acme')); - $container->register('my_service', $definition); + $container->setDefinition('my_service', $definition); .. tip:: @@ -701,15 +763,24 @@ You can add a processor globally: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php - $definition = new Definition('Monolog\Processor\IntrospectionProcessor'); - $definition->addTag('monolog.processor'); - $container->register('my_service', $definition); + $container + ->register('my_service', 'Monolog\Processor\IntrospectionProcessor') + ->addTag('monolog.processor') + ; .. tip:: @@ -731,15 +802,24 @@ attribute: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php - $definition = new Definition('Monolog\Processor\IntrospectionProcessor'); - $definition->addTag('monolog.processor', array('handler' => 'firephp'); - $container->register('my_service', $definition); + $container + ->register('my_service', 'Monolog\Processor\IntrospectionProcessor') + ->addTag('monolog.processor', array('handler' => 'firephp')) + ; You can also add a processor for a specific logging channel by using the ``channel`` attribute. This will register the processor only for the ``security`` logging @@ -757,15 +837,24 @@ channel used in the Security component: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php - $definition = new Definition('Monolog\Processor\IntrospectionProcessor'); - $definition->addTag('monolog.processor', array('channel' => 'security'); - $container->register('my_service', $definition); + $container + ->register('my_service', 'Monolog\Processor\IntrospectionProcessor') + ->addTag('monolog.processor', array('channel' => 'security')) + ; .. note:: @@ -792,9 +881,20 @@ of your configuration, and tag it with ``routing.loader``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -899,9 +999,20 @@ templates): .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -959,9 +1070,20 @@ Now, register your loader as a service and tag it with ``translation.loader``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -1043,10 +1165,20 @@ option: ``alias``, which defines the name of the extractor:: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -1097,10 +1229,20 @@ This is the name that's used to determine which dumper should be used. .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -1132,9 +1274,20 @@ configuration, and tag it with ``twig.extension``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -1165,9 +1318,17 @@ also have to be added as regular services: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php @@ -1198,9 +1359,20 @@ the new loader and tag it with ``twig.loader``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php From a5f54e3d91d154b6c04d6265ba002865e4f20ef2 Mon Sep 17 00:00:00 2001 From: gerryvdm Date: Fri, 22 Aug 2014 17:21:40 +0200 Subject: [PATCH 6/6] Update voters.rst Corrected the service name to be injected0 --- cookbook/security/voters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/security/voters.rst b/cookbook/security/voters.rst index 1760cb43db7..e27f922a700 100644 --- a/cookbook/security/voters.rst +++ b/cookbook/security/voters.rst @@ -32,7 +32,7 @@ access, not to grant access. Creating a custom Voter ----------------------- -To blacklist a user based on its IP, you can use the ``request`` service +To blacklist a user based on its IP, you can use the ``request_stack`` service and compare the IP address against a set of blacklisted IP addresses: .. code-block:: php