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