diff --git a/book/validation.rst b/book/validation.rst index 6c58296c5ab..d3a39f33c22 100644 --- a/book/validation.rst +++ b/book/validation.rst @@ -1118,7 +1118,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 diff --git a/cookbook/logging/monolog_email.rst b/cookbook/logging/monolog_email.rst index 7ce812c3672..aacf2a6cc29 100644 --- a/cookbook/logging/monolog_email.rst +++ b/cookbook/logging/monolog_email.rst @@ -58,10 +58,18 @@ it is broken down. name="swift" type="swift_mailer" from-email="error@example.com" - to-email="error@example.com" subject="An Error Occurred!" - level="debug" - /> + level="debug"> + + error@example.com + + + + 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 diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 0390098bdab..0c34d6cd7ab 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -359,32 +359,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 1353b62452d..204c91aecc2 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -104,21 +104,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', )); @@ -158,17 +163,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'), )); @@ -285,9 +299,17 @@ the value to ``null``: .. code-block:: xml - - - + + + + + + + .. code-block:: php @@ -373,15 +395,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/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 112620da68b..9df3332a749 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -24,7 +24,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: @@ -72,7 +72,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 f936c0da7f3..b2423282139 100644 --- a/reference/constraints/Image.rst +++ b/reference/constraints/Image.rst @@ -92,7 +92,6 @@ it is between a certain size, add the following: maxWidth: 400 minHeight: 200 maxHeight: 400 - .. code-block:: php-annotations @@ -137,15 +136,14 @@ it is between a certain size, add the following: .. code-block:: php // src/Acme/BlogBundle/Entity/Author.php - namespace Acme/BlogBundle/Entity + + 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) { $metadata->addPropertyConstraint('headshot', new Assert\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 fb0be64a49b..6883f0e1aa4 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -49,6 +49,8 @@ on an object that will contain an ISBN. .. code-block:: php-annotations // src/Acme/BookcaseBundle/Entity/Book.php + namespace Acme\BookcaseBundle\Entity; + use Symfony\Component\Validator\Constraints as Assert; class Book @@ -65,14 +67,20 @@ on an object that will contain an ISBN. .. 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 70ca0912888..0dca2831300 100644 --- a/reference/constraints/Luhn.rst +++ b/reference/constraints/Luhn.rst @@ -35,7 +35,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; @@ -67,7 +67,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 4f1e588ab17..489f01675b9 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 @@ -186,8 +186,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:: @@ -205,7 +205,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 @@ -241,7 +241,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 dd751890fb9..c622244a0e4 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 1383172aaed..dee677b1d78 100644 --- a/reference/constraints/UserPassword.rst +++ b/reference/constraints/UserPassword.rst @@ -32,7 +32,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: @@ -58,15 +58,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 18fce432bff..0e4de98e90c 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -128,9 +128,17 @@ And then register it as a tagged service: .. code-block:: xml - - + + + + + + + + .. code-block:: php @@ -179,9 +187,17 @@ Second, define a service: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php @@ -331,9 +347,20 @@ the ``form.type_extension`` tag: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -403,9 +430,17 @@ Then register this class and tag it with ``kernel.cache_clearer``: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php @@ -466,9 +501,17 @@ To register your warmer with Symfony, give it the ``kernel.cache_warmer`` tag: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php @@ -611,9 +654,20 @@ configuration, and tag it with ``kernel.event_subscriber``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -666,16 +720,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:: @@ -712,15 +774,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:: @@ -742,15 +813,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 @@ -768,15 +848,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:: @@ -803,9 +892,20 @@ of your configuration, and tag it with ``routing.loader``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -910,9 +1010,20 @@ templates): .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -970,9 +1081,20 @@ Now, register your loader as a service and tag it with ``translation.loader``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -1051,10 +1173,20 @@ option: ``alias``, which defines the name of the extractor:: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -1102,10 +1234,20 @@ This is the name that's used to determine which dumper should be used. .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -1137,9 +1279,20 @@ configuration, and tag it with ``twig.extension``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php @@ -1170,9 +1323,17 @@ also have to be added as regular services: .. code-block:: xml - - - + + + + + + + + + .. code-block:: php @@ -1203,9 +1364,20 @@ the new loader and tag it with ``twig.loader``: .. code-block:: xml - - - + + + + + + + + + + .. code-block:: php 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`. diff --git a/reference/forms/types/textarea.rst b/reference/forms/types/textarea.rst index 71a4069b995..a75ffbb0f27 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