From c765aa5f5983e6064e987d51745c2456953052a9 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 2 May 2015 10:58:51 +0200 Subject: [PATCH 1/2] Let docbot review the constraint docs --- reference/constraints/All.rst | 20 +++---- reference/constraints/Blank.rst | 24 ++++---- reference/constraints/Callback.rst | 59 +++++++++++-------- reference/constraints/CardScheme.rst | 20 ++++--- reference/constraints/Choice.rst | 53 +++++++++-------- reference/constraints/Collection.rst | 57 ++++++++++-------- reference/constraints/Count.rst | 22 +++---- reference/constraints/Currency.rst | 4 +- reference/constraints/EqualTo.rst | 4 +- reference/constraints/File.rst | 32 +++++----- reference/constraints/GreaterThan.rst | 12 ++-- reference/constraints/GreaterThanOrEqual.rst | 12 ++-- reference/constraints/Iban.rst | 16 +++-- reference/constraints/Image.rst | 20 +++---- reference/constraints/Ip.rst | 36 +++++++---- reference/constraints/Isbn.rst | 14 +++-- reference/constraints/Issn.rst | 3 +- reference/constraints/Length.rst | 37 +++++++----- reference/constraints/LessThan.rst | 4 +- reference/constraints/LessThanOrEqual.rst | 12 ++-- reference/constraints/Locale.rst | 7 ++- reference/constraints/Luhn.rst | 6 +- reference/constraints/NotBlank.rst | 8 +-- reference/constraints/NotEqualTo.rst | 4 +- reference/constraints/NotIdenticalTo.rst | 12 ++-- reference/constraints/NotNull.rst | 4 +- reference/constraints/Range.rst | 12 ++-- reference/constraints/Regex.rst | 33 ++++++----- reference/constraints/True.rst | 8 +-- reference/constraints/Type.rst | 21 ++++--- reference/constraints/UniqueEntity.rst | 28 ++++----- reference/constraints/Url.rst | 2 +- reference/constraints/UserPassword.rst | 33 ++++++----- reference/constraints/Valid.rst | 26 ++++---- .../_comparison-value-option.rst.inc | 2 +- 35 files changed, 365 insertions(+), 302 deletions(-) diff --git a/reference/constraints/All.rst b/reference/constraints/All.rst index 7c3a2f2a311..34a59dfc9fe 100644 --- a/reference/constraints/All.rst +++ b/reference/constraints/All.rst @@ -4,20 +4,20 @@ All When applied to an array (or Traversable object), this constraint allows you to apply a collection of constraints to each element of the array. -+----------------+------------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+------------------------------------------------------------------------+ -| Options | - `constraints`_ | -+----------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` | -+----------------+------------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` | -+----------------+------------------------------------------------------------------------+ ++----------------+-------------------------------------------------------------------+ +| Applies to | :ref:`property or method ` | ++----------------+-------------------------------------------------------------------+ +| Options | - `constraints`_ | ++----------------+-------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` | ++----------------+-------------------------------------------------------------------+ +| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` | ++----------------+-------------------------------------------------------------------+ Basic Usage ----------- -Suppose that you have an array of strings, and you want to validate each +Suppose that you have an array of strings and you want to validate each entry in that array: .. configuration-block:: diff --git a/reference/constraints/Blank.rst b/reference/constraints/Blank.rst index 1f85334443f..ce279e0630a 100644 --- a/reference/constraints/Blank.rst +++ b/reference/constraints/Blank.rst @@ -3,18 +3,18 @@ Blank Validates that a value is blank, defined as equal to a blank string or equal to ``null``. To force that a value strictly be equal to ``null``, see the -:doc:`/reference/constraints/Null` constraint. To force that a value is *not* -blank, see :doc:`/reference/constraints/NotBlank`. - -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `message`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` | -+----------------+-----------------------------------------------------------------------+ +:doc:`/reference/constraints/Null` constraint. To force that a value is +*not* blank, see :doc:`/reference/constraints/NotBlank`. + ++----------------+---------------------------------------------------------------------+ +| Applies to | :ref:`property or method ` | ++----------------+---------------------------------------------------------------------+ +| Options | - `message`_ | ++----------------+---------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` | ++----------------+---------------------------------------------------------------------+ +| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` | ++----------------+---------------------------------------------------------------------+ Basic Usage ----------- diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index 491963cd508..5cd786fae69 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -2,10 +2,10 @@ Callback ======== The purpose of the Callback assertion is to let you create completely custom -validation rules and to assign any validation errors to specific fields on -your object. If you're using validation with forms, this means that you can -make these custom errors display next to a specific field, instead of simply -at the top of your form. +validation rules and to assign any validation errors to specific fields +on your object. If you're using validation with forms, this means that you +can make these custom errors display next to a specific field, instead of +simply at the top of your form. This process works by specifying one or more *callback* methods, each of which will be called during the validation process. Each of those methods @@ -92,9 +92,9 @@ Setup The Callback Method ------------------- -The callback method is passed a special ``ExecutionContextInterface`` object. You -can set "violations" directly on this object and determine to which field -those errors should be attributed:: +The callback method is passed a special ``ExecutionContextInterface`` object. +You can set "violations" directly on this object and determine to which +field those errors should be attributed:: // ... use Symfony\Component\Validator\ExecutionContextInterface; @@ -111,7 +111,12 @@ those errors should be attributed:: // 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); + $context->addViolationAt( + 'firstname', + 'This name sounds totally fake!', + array(), + null + ); } } } @@ -129,9 +134,10 @@ process. Each method can be one of the following formats: 1) **String method name** - If the name of a method is a simple string (e.g. ``isAuthorValid``), that - method will be called on the same object that's being validated and the - ``ExecutionContextInterface`` will be the only argument (see the above example). + If the name of a method is a simple string (e.g. ``isAuthorValid``), + that method will be called on the same object that's being validated + and the ``ExecutionContextInterface`` will be the only argument (see + the above example). 2) **Static array callback** @@ -197,15 +203,19 @@ process. Each method can be one of the following formats: { $metadata->addConstraint(new Callback(array( 'methods' => array( - array('Acme\BlogBundle\MyStaticValidatorClass', 'isAuthorValid'), + array( + 'Acme\BlogBundle\MyStaticValidatorClass', + 'isAuthorValid', + ), ), ))); } } - In this case, the static method ``isAuthorValid`` will be called on the - ``Acme\BlogBundle\MyStaticValidatorClass`` class. It's passed both the original - object being validated (e.g. ``Author``) as well as the ``ExecutionContextInterface``:: + In this case, the static method ``isAuthorValid`` will be called on + the ``Acme\BlogBundle\MyStaticValidatorClass`` class. It's passed both + the original object being validated (e.g. ``Author``) as well as the + ``ExecutionContextInterface``:: namespace Acme\BlogBundle; @@ -214,17 +224,20 @@ process. Each method can be one of the following formats: class MyStaticValidatorClass { - public static function isAuthorValid(Author $author, ExecutionContextInterface $context) - { + public static function isAuthorValid( + Author $author, + ExecutionContextInterface $context + ) { // ... } } .. tip:: - If you specify your ``Callback`` constraint via PHP, then you also have - the option to make your callback either a PHP closure or a non-static - callback. It is *not* currently possible, however, to specify a :term:`service` - as a constraint. To validate using a service, you should - :doc:`create a custom validation constraint ` - and add that new constraint to your class. + If you specify your ``Callback`` constraint via PHP, then you also + have the option to make your callback either a PHP closure or a + non-static callback. It is *not* currently possible, however, to + specify a :term:`service` as a constraint. To validate using a service, + you should :doc:`create a custom validation constraint + ` and add that new constraint + to your class. diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index 7078ca4635c..efc7312a198 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -4,9 +4,9 @@ CardScheme .. versionadded:: 2.2 The ``CardScheme`` constraint was introduced in Symfony 2.2. -This constraint ensures that a credit card number is valid for a given credit card -company. It can be used to validate the number before trying to initiate a payment -through a payment gateway. +This constraint ensures that a credit card number is valid for a given credit +card company. It can be used to validate the number before trying to initiate +a payment through a payment gateway. +----------------+--------------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | @@ -37,7 +37,10 @@ on an object that will contain a credit card number. class Transaction { /** - * @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.") + * @Assert\CardScheme( + * schemes={"VISA"}, + * message="Your credit card number is invalid." + * ) */ protected $cardNumber; } @@ -103,9 +106,9 @@ schemes **type**: ``mixed`` [:ref:`default option `] -This option is required and represents the name of the number scheme used to -validate the credit card number, it can either be a string or an array. Valid -values are: +This option is required and represents the name of the number scheme used +to validate the credit card number, it can either be a string or an array. +Valid values are: * ``AMEX`` * ``CHINA_UNIONPAY`` @@ -118,7 +121,8 @@ values are: * ``MASTERCARD`` * ``VISA`` -For more information about the used schemes, see `Wikipedia: Issuer identification number (IIN)`_. +For more information about the used schemes, see +`Wikipedia: Issuer identification number (IIN)`_. message ~~~~~~~ diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index 5fa2a2d3662..e356ffe33d4 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -5,24 +5,24 @@ This constraint is used to ensure that the given value is one of a given set of *valid* choices. It can also be used to validate that each item in an array of items is one of those valid choices. -+----------------+-----------------------------------------------------------------------+ -| Applies to | :ref:`property or method ` | -+----------------+-----------------------------------------------------------------------+ -| Options | - `choices`_ | -| | - `callback`_ | -| | - `multiple`_ | -| | - `min`_ | -| | - `max`_ | -| | - `message`_ | -| | - `multipleMessage`_ | -| | - `minMessage`_ | -| | - `maxMessage`_ | -| | - `strict`_ | -+----------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` | -+----------------+-----------------------------------------------------------------------+ -| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` | -+----------------+-----------------------------------------------------------------------+ ++----------------+----------------------------------------------------------------------+ +| Applies to | :ref:`property or method ` | ++----------------+----------------------------------------------------------------------+ +| Options | - `choices`_ | +| | - `callback`_ | +| | - `multiple`_ | +| | - `min`_ | +| | - `max`_ | +| | - `message`_ | +| | - `multipleMessage`_ | +| | - `minMessage`_ | +| | - `maxMessage`_ | +| | - `strict`_ | ++----------------+----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` | ++----------------+----------------------------------------------------------------------+ +| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` | ++----------------+----------------------------------------------------------------------+ Basic Usage ----------- @@ -275,8 +275,8 @@ callback **type**: ``string|array|Closure`` This is a callback method that can be used instead of the `choices`_ option -to return the choices array. See `Supplying the Choices with a Callback Function`_ -for details on its usage. +to return the choices array. See +`Supplying the Choices with a Callback Function`_ for details on its usage. multiple ~~~~~~~~ @@ -313,16 +313,17 @@ message **type**: ``string`` **default**: ``The value you selected is not a valid choice.`` -This is the message that you will receive if the ``multiple`` option is set -to ``false``, and the underlying value is not in the valid array of choices. +This is the message that you will receive if the ``multiple`` option is +set to ``false`` and the underlying value is not in the valid array of +choices. multipleMessage ~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``One or more of the given values is invalid.`` -This is the message that you will receive if the ``multiple`` option is set -to ``true``, and one of the values on the underlying array being checked +This is the message that you will receive if the ``multiple`` option is +set to ``true`` and one of the values on the underlying array being checked is not in the array of valid choices. minMessage @@ -347,5 +348,5 @@ strict **type**: ``Boolean`` **default**: ``false`` If true, the validator will also check the type of the input value. Specifically, -this value is passed to as the third argument to the PHP :phpfunction:`in_array` method -when checking to see if a value is in the valid choices array. +this value is passed to as the third argument to the PHP :phpfunction:`in_array` +method when checking to see if a value is in the valid choices array. diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index def91862c3f..a58ed119956 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -5,7 +5,8 @@ This constraint is used when the underlying data is a collection (i.e. an array or an object that implements ``Traversable`` and ``ArrayAccess``), but you'd like to validate different keys of that collection in different ways. For example, you might validate the ``email`` key using the ``Email`` -constraint and the ``inventory`` key of the collection with the ``Range`` constraint. +constraint and the ``inventory`` key of the collection with the ``Range`` +constraint. This constraint can also make sure that certain collection keys are present and that extra keys are not present. @@ -27,8 +28,8 @@ and that extra keys are not present. Basic Usage ----------- -The ``Collection`` constraint allows you to validate the different keys of -a collection individually. Take the following example:: +The ``Collection`` constraint allows you to validate the different keys +of a collection individually. Take the following example:: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; @@ -47,8 +48,9 @@ a collection individually. Take the following example:: } To validate that the ``personal_email`` element of the ``profileData`` array -property is a valid email address and that the ``short_bio`` element is not -blank but is no longer than 100 characters in length, you would do the following: +property is a valid email address and that the ``short_bio`` element is +not blank but is no longer than 100 characters in length, you would do the +following: .. configuration-block:: @@ -161,31 +163,33 @@ Presence and Absence of Fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, this constraint validates more than simply whether or not the -individual fields in the collection pass their assigned constraints. In fact, -if any keys of a collection are missing or if there are any unrecognized +individual fields in the collection pass their assigned constraints. In +fact, if any keys of a collection are missing or if there are any unrecognized keys in the collection, validation errors will be thrown. -If you would like to allow for keys to be absent from the collection or if -you would like "extra" keys to be allowed in the collection, you can modify -the `allowMissingFields`_ and `allowExtraFields`_ options respectively. In -the above example, the ``allowMissingFields`` option was set to true, meaning -that if either of the ``personal_email`` or ``short_bio`` elements were missing -from the ``$personalData`` property, no validation error would occur. +If you would like to allow for keys to be absent from the collection or +if you would like "extra" keys to be allowed in the collection, you can +modify the `allowMissingFields`_ and `allowExtraFields`_ options respectively. +In the above example, the ``allowMissingFields`` option was set to true, +meaning that if either of the ``personal_email`` or ``short_bio`` elements +were missing from the ``$personalData`` property, no validation error would +occur. -Required and optional Field Constraints +Required and Optional Field Constraints ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. versionadded:: 2.3 The ``Required`` and ``Optional`` constraints were moved to the namespace ``Symfony\Component\Validator\Constraints\`` in Symfony 2.3. -Constraints for fields within a collection can be wrapped in the ``Required`` or -``Optional`` constraint to control whether they should always be applied (``Required``) -or only applied when the field is present (``Optional``). +Constraints for fields within a collection can be wrapped in the ``Required`` +or ``Optional`` constraint to control whether they should always be applied +(``Required``) or only applied when the field is present (``Optional``). -For instance, if you want to require that the ``personal_email`` field of the -``profileData`` array is not blank and is a valid email but the ``alternate_email`` -field is optional but must be a valid email if supplied, you can do the following: +For instance, if you want to require that the ``personal_email`` field of +the ``profileData`` array is not blank and is a valid email but the +``alternate_email`` field is optional but must be a valid email if supplied, +you can do the following: .. configuration-block:: @@ -270,7 +274,9 @@ field is optional but must be a valid email if supplied, you can do the followin { $metadata->addPropertyConstraint('profileData', new Assert\Collection(array( 'fields' => array( - 'personal_email' => new Assert\Required(array(new Assert\NotBlank(), new Assert\Email())), + 'personal_email' => new Assert\Required( + array(new Assert\NotBlank(), new Assert\Email()) + ), 'alternate_email' => new Assert\Optional(new Assert\Email()), ), ))); @@ -291,7 +297,7 @@ fields **type**: ``array`` [:ref:`default option `] -This option is required, and is an associative array defining all of the +This option is required and is an associative array defining all of the keys in the collection and, for each key, exactly which validator(s) should be executed against that element of the collection. @@ -309,7 +315,8 @@ extraFieldsMessage **type**: ``Boolean`` **default**: ``The fields {{ fields }} were not expected.`` -The message shown if `allowExtraFields`_ is false and an extra field is detected. +The message shown if `allowExtraFields`_ is false and an extra field is +detected. allowMissingFields ~~~~~~~~~~~~~~~~~~ @@ -317,8 +324,8 @@ allowMissingFields **type**: ``Boolean`` **default**: false If this option is set to ``false`` and one or more fields from the `fields`_ -option are not present in the underlying collection, a validation error will -be returned. If set to ``true``, it's ok if some fields in the `fields`_ +option are not present in the underlying collection, a validation error +will be returned. If set to ``true``, it's ok if some fields in the `fields`_ option are not present in the underlying collection. missingFieldsMessage diff --git a/reference/constraints/Count.rst b/reference/constraints/Count.rst index 0685b87bfe0..b51c798963c 100644 --- a/reference/constraints/Count.rst +++ b/reference/constraints/Count.rst @@ -1,8 +1,8 @@ Count ===== -Validates that a given collection's (i.e. an array or an object that implements Countable) -element count is *between* some minimum and maximum value. +Validates that a given collection's (i.e. an array or an object that implements +Countable) element count is *between* some minimum and maximum value. +----------------+---------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | @@ -107,35 +107,37 @@ min **type**: ``integer`` -This required option is the "min" count value. Validation will fail if the given -collection elements count is **less** than this min value. +This required option is the "min" count value. Validation will fail if the +given collection elements count is **less** than this min value. max ~~~ **type**: ``integer`` -This required option is the "max" count value. Validation will fail if the given -collection elements count is **greater** than this max value. +This required option is the "max" count value. Validation will fail if the +given collection elements count is **greater** than this max value. minMessage ~~~~~~~~~~ **type**: ``string`` **default**: ``This collection should contain {{ limit }} elements or more.`` -The message that will be shown if the underlying collection elements count is less than the `min`_ option. +The message that will be shown if the underlying collection elements count +is less than the `min`_ option. maxMessage ~~~~~~~~~~ **type**: ``string`` **default**: ``This collection should contain {{ limit }} elements or less.`` -The message that will be shown if the underlying collection elements count is more than the `max`_ option. +The message that will be shown if the underlying collection elements count +is more than the `max`_ option. exactMessage ~~~~~~~~~~~~ **type**: ``string`` **default**: ``This collection should contain exactly {{ limit }} elements.`` -The message that will be shown if min and max values are equal and the underlying collection elements -count is not exactly this value. +The message that will be shown if min and max values are equal and the underlying +collection elements count is not exactly this value. diff --git a/reference/constraints/Currency.rst b/reference/constraints/Currency.rst index ae5cad8cec7..5292d92166f 100644 --- a/reference/constraints/Currency.rst +++ b/reference/constraints/Currency.rst @@ -19,8 +19,8 @@ Validates that a value is a valid `3-letter ISO 4217`_ currency name. Basic Usage ----------- -If you want to ensure that the ``currency`` property of an ``Order`` is a valid -currency, you could do the following: +If you want to ensure that the ``currency`` property of an ``Order`` is +a valid currency, you could do the following: .. configuration-block:: diff --git a/reference/constraints/EqualTo.rst b/reference/constraints/EqualTo.rst index e78edeb2496..d9408eb6e65 100644 --- a/reference/constraints/EqualTo.rst +++ b/reference/constraints/EqualTo.rst @@ -4,8 +4,8 @@ EqualTo .. versionadded:: 2.3 The ``EqualTo`` constraint was introduced in Symfony 2.3. -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`. +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:: diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 7a87bb737e9..76d6fb9c0ec 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -3,8 +3,8 @@ File Validates that a value is a valid "file", which can be one of the following: -* A string (or object with a ``__toString()`` method) path to an existing file; - +* A string (or object with a ``__toString()`` method) path to an existing + file; * A valid :class:`Symfony\\Component\\HttpFoundation\\File\\File` object (including objects of class :class:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile`). @@ -38,10 +38,10 @@ Basic Usage ----------- This constraint is most commonly used on a property that will be rendered -in a form as a :doc:`file ` form type. For example, -suppose you're creating an author form where you can upload a "bio" PDF for -the author. In your form, the ``bioFile`` property would be a ``file`` type. -The ``Author`` class might look as follows:: +in a form as a :doc:`file ` form type. For +example, suppose you're creating an author form where you can upload a "bio" +PDF for the author. In your form, the ``bioFile`` property would be a ``file`` +type. The ``Author`` class might look as follows:: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; @@ -63,7 +63,7 @@ The ``Author`` class might look as follows:: } } -To guarantee that the ``bioFile`` ``File`` object is valid, and that it is +To guarantee that the ``bioFile`` ``File`` object is valid and that it is below a certain file size and a valid PDF, add the following: .. configuration-block:: @@ -155,17 +155,18 @@ maxSize **type**: ``mixed`` -If set, the size of the underlying file must be below this file size in order -to be valid. The size of the file can be given in one of the following formats: +If set, the size of the underlying file must be below this file size in +order to be valid. The size of the file can be given in one of the following +formats: * **bytes**: To specify the ``maxSize`` in bytes, pass a value that is entirely numeric (e.g. ``4096``); -* **kilobytes**: To specify the ``maxSize`` in kilobytes, pass a number and - suffix it with a lowercase "k" (e.g. ``200k``); +* **kilobytes**: To specify the ``maxSize`` in kilobytes, pass a number + and suffix it with a lowercase "k" (e.g. ``200k``); -* **megabytes**: To specify the ``maxSize`` in megabytes, pass a number and - suffix it with a capital "M" (e.g. ``4M``). +* **megabytes**: To specify the ``maxSize`` in megabytes, pass a number + and suffix it with a capital "M" (e.g. ``4M``). mimeTypes ~~~~~~~~~ @@ -232,8 +233,7 @@ uploadErrorMessage **type**: ``string`` **default**: ``The file could not be uploaded.`` The message that is displayed if the uploaded file could not be uploaded -for some unknown reason, such as the file upload failed or it couldn't be written -to disk. - +for some unknown reason, such as the file upload failed or it couldn't be +written to disk. .. _`IANA website`: http://www.iana.org/assignments/media-types/index.html diff --git a/reference/constraints/GreaterThan.rst b/reference/constraints/GreaterThan.rst index f553786a0ed..d973a262867 100644 --- a/reference/constraints/GreaterThan.rst +++ b/reference/constraints/GreaterThan.rst @@ -4,8 +4,8 @@ GreaterThan .. versionadded:: 2.3 The ``GreaterThan`` constraint was introduced in Symfony 2.3. -Validates that a value is greater than another value, defined in the options. To -force that a value is greater than or equal to another value, see +Validates that a value is greater than another value, defined in the options. +To force that a value is greater than or equal to another value, see :doc:`/reference/constraints/GreaterThanOrEqual`. To force a value is less than another value, see :doc:`/reference/constraints/LessThan`. @@ -23,8 +23,8 @@ than another value, see :doc:`/reference/constraints/LessThan`. Basic Usage ----------- -If you want to ensure that the ``age`` of a ``Person`` class is greater than -``18``, you could do the following: +If you want to ensure that the ``age`` of a ``Person`` class is greater +than ``18``, you could do the following: .. configuration-block:: @@ -99,5 +99,5 @@ message **type**: ``string`` **default**: ``This value should be greater than {{ compared_value }}.`` -This is the message that will be shown if the value is not greater than the -comparison value. +This is the message that will be shown if the value is not greater than +the comparison value. diff --git a/reference/constraints/GreaterThanOrEqual.rst b/reference/constraints/GreaterThanOrEqual.rst index 4a10e2355eb..50b31db48da 100644 --- a/reference/constraints/GreaterThanOrEqual.rst +++ b/reference/constraints/GreaterThanOrEqual.rst @@ -4,8 +4,8 @@ GreaterThanOrEqual .. versionadded:: 2.3 The ``GreaterThanOrEqual`` constraint was introduced in Symfony 2.3. -Validates that a value is greater than or equal to another value, defined in -the options. To force that a value is greater than another value, see +Validates that a value is greater than or equal to another value, defined +in the options. To force that a value is greater than another value, see :doc:`/reference/constraints/GreaterThan`. +----------------+----------------------------------------------------------------------------------+ @@ -22,8 +22,8 @@ the options. To force that a value is greater than another value, see Basic Usage ----------- -If you want to ensure that the ``age`` of a ``Person`` class is greater than -or equal to ``18``, you could do the following: +If you want to ensure that the ``age`` of a ``Person`` class is greater +than or equal to ``18``, you could do the following: .. configuration-block:: @@ -98,5 +98,5 @@ message **type**: ``string`` **default**: ``This value should be greater than or equal to {{ compared_value }}.`` -This is the message that will be shown if the value is not greater than or equal -to the comparison value. +This is the message that will be shown if the value is not greater than +or equal to the comparison value. diff --git a/reference/constraints/Iban.rst b/reference/constraints/Iban.rst index bb60414a953..e485a0af457 100644 --- a/reference/constraints/Iban.rst +++ b/reference/constraints/Iban.rst @@ -4,10 +4,10 @@ Iban .. versionadded:: 2.3 The Iban constraint was introduced in Symfony 2.3. -This constraint is used to ensure that a bank account number has the proper format of -an `International Bank Account Number (IBAN)`_. IBAN is an internationally agreed means -of identifying bank accounts across national borders with a reduced risk of propagating -transcription errors. +This constraint is used to ensure that a bank account number has the proper +format of an `International Bank Account Number (IBAN)`_. IBAN is an +internationally agreed means of identifying bank accounts across national +borders with a reduced risk of propagating transcription errors. +----------------+-----------------------------------------------------------------------+ | Applies to | :ref:`property or method` | @@ -37,7 +37,9 @@ will contain an International Bank Account Number. class Transaction { /** - * @Assert\Iban(message = "This is not a valid International Bank Account Number (IBAN).") + * @Assert\Iban( + * message="This is not a valid International Bank Account Number (IBAN)." + * ) */ protected $bankAccountNumber; } @@ -62,7 +64,9 @@ will contain an International Bank Account Number. - + diff --git a/reference/constraints/Image.rst b/reference/constraints/Image.rst index e2c0b55cc4c..9e62ad5a65e 100644 --- a/reference/constraints/Image.rst +++ b/reference/constraints/Image.rst @@ -2,14 +2,14 @@ Image ===== The Image constraint works exactly like the :doc:`File ` -constraint, except that its `mimeTypes`_ and `mimeTypesMessage` options are -automatically setup to work for image files specifically. +constraint, except that its `mimeTypes`_ and `mimeTypesMessage`_ options +are automatically setup to work for image files specifically. Additionally, as of Symfony 2.1, it has options so you can validate against the width and height of the image. -See the :doc:`File ` constraint for the bulk of -the documentation on this constraint. +See the :doc:`File ` constraint for the bulk +of the documentation on this constraint. +----------------+-----------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | @@ -36,10 +36,10 @@ Basic Usage ----------- This constraint is most commonly used on a property that will be rendered -in a form as a :doc:`file ` form type. For example, -suppose you're creating an author form where you can upload a "headshot" -image for the author. In your form, the ``headshot`` property would be a -``file`` type. The ``Author`` class might look as follows:: +in a form as a :doc:`file ` form type. For +example, suppose you're creating an author form where you can upload a +"headshot" image for the author. In your form, the ``headshot`` property +would be a ``file`` type. The ``Author`` class might look as follows:: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; @@ -61,8 +61,8 @@ image for the author. In your form, the ``headshot`` property would be a } } -To guarantee that the ``headshot`` ``File`` object is a valid image and that -it is between a certain size, add the following: +To guarantee that the ``headshot`` ``File`` object is a valid image and +that it is between a certain size, add the following: .. configuration-block:: diff --git a/reference/constraints/Ip.rst b/reference/constraints/Ip.rst index a07715cb2b9..93f7a87ec3f 100644 --- a/reference/constraints/Ip.rst +++ b/reference/constraints/Ip.rst @@ -88,27 +88,39 @@ of a variety of different values: **All ranges** -* ``4`` - Validates for IPv4 addresses -* ``6`` - Validates for IPv6 addresses -* ``all`` - Validates all IP formats +``4`` + Validates for IPv4 addresses +``6`` + Validates for IPv6 addresses +``all`` + Validates all IP formats **No private ranges** -* ``4_no_priv`` - Validates for IPv4 but without private IP ranges -* ``6_no_priv`` - Validates for IPv6 but without private IP ranges -* ``all_no_priv`` - Validates for all IP formats but without private IP ranges +``4_no_priv`` + Validates for IPv4 but without private IP ranges +``6_no_priv`` + Validates for IPv6 but without private IP ranges +``all_no_priv`` + Validates for all IP formats but without private IP ranges **No reserved ranges** -* ``4_no_res`` - Validates for IPv4 but without reserved IP ranges -* ``6_no_res`` - Validates for IPv6 but without reserved IP ranges -* ``all_no_res`` - Validates for all IP formats but without reserved IP ranges +``4_no_res`` + Validates for IPv4 but without reserved IP ranges +``6_no_res`` + Validates for IPv6 but without reserved IP ranges +``all_no_res`` + Validates for all IP formats but without reserved IP ranges **Only public ranges** -* ``4_public`` - Validates for IPv4 but without private and reserved ranges -* ``6_public`` - Validates for IPv6 but without private and reserved ranges -* ``all_public`` - Validates for all IP formats but without private and reserved ranges +``4_public`` + Validates for IPv4 but without private and reserved ranges +``6_public`` + Validates for IPv6 but without private and reserved ranges +``all_public`` + Validates for all IP formats but without private and reserved ranges message ~~~~~~~ diff --git a/reference/constraints/Isbn.rst b/reference/constraints/Isbn.rst index a69cf17ed69..4b855ca85d7 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -25,7 +25,7 @@ Basic Usage ----------- To use the ``Isbn`` validator, simply apply it to a property or method -on an object that will contain a ISBN number. +on an object that will contain a ISBN number. .. configuration-block:: @@ -72,7 +72,9 @@ on an object that will contain a ISBN number. - + @@ -108,16 +110,16 @@ isbn10 **type**: ``boolean`` -If this required option is set to ``true`` the constraint will check if the -code is a valid ISBN-10 code. +If this required option is set to ``true`` the constraint will check if +the code is a valid ISBN-10 code. isbn13 ~~~~~~ **type**: ``boolean`` -If this required option is set to ``true`` the constraint will check if the -code is a valid ISBN-13 code. +If this required option is set to ``true`` the constraint will check if +the code is a valid ISBN-13 code. isbn10Message ~~~~~~~~~~~~~ diff --git a/reference/constraints/Issn.rst b/reference/constraints/Issn.rst index c89341d10fe..d9cd7b37e17 100644 --- a/reference/constraints/Issn.rst +++ b/reference/constraints/Issn.rst @@ -4,7 +4,8 @@ Issn .. versionadded:: 2.3 The Issn constraint was introduced in Symfony 2.3. -Validates that a value is a valid `International Standard Serial Number (ISSN)`_. +Validates that a value is a valid +`International Standard Serial Number (ISSN)`_. +----------------+-----------------------------------------------------------------------+ | Applies to | :ref:`property or method` | diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index 84a8bf32f15..034024e17b5 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -1,7 +1,8 @@ Length ====== -Validates that a given string length is *between* some minimum and maximum value. +Validates that a given string length is *between* some minimum and maximum +value. +----------------+----------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | @@ -21,8 +22,8 @@ Validates that a given string length is *between* some minimum and maximum value Basic Usage ----------- -To verify that the ``firstName`` field length of a class is between "2" and -"50", you might add the following: +To verify that the ``firstName`` field length of a class is between "2" +and "50", you might add the following: .. configuration-block:: @@ -71,8 +72,12 @@ To verify that the ``firstName`` field length of a class is between "2" and - - + + @@ -107,40 +112,42 @@ min **type**: ``integer`` -This required option is the "min" length value. Validation will fail if the given -value's length is **less** than this min value. +This required option is the "min" length value. Validation will fail if +the given value's length is **less** than this min value. max ~~~ **type**: ``integer`` -This required option is the "max" length value. Validation will fail if the given -value's length is **greater** than this max value. +This required option is the "max" length value. Validation will fail if +the given value's length is **greater** than this max value. charset ~~~~~~~ **type**: ``string`` **default**: ``UTF-8`` -The charset to be used when computing value's length. The :phpfunction:`grapheme_strlen` PHP -function is used if available. If not, the :phpfunction:`mb_strlen` PHP function -is used if available. If neither are available, the :phpfunction:`strlen` PHP function -is used. +The charset to be used when computing value's length. The +:phpfunction:`grapheme_strlen` PHP function is used if available. If not, +the :phpfunction:`mb_strlen` PHP function is used if available. If neither +are available, the :phpfunction:`strlen` PHP function is used. minMessage ~~~~~~~~~~ **type**: ``string`` **default**: ``This value is too short. It should have {{ limit }} characters or more.`` -The message that will be shown if the underlying value's length is less than the `min`_ option. +The message that will be shown if the underlying value's length is less +than the `min`_ option. maxMessage ~~~~~~~~~~ **type**: ``string`` **default**: ``This value is too long. It should have {{ limit }} characters or less.`` -The message that will be shown if the underlying value's length is more than the `max`_ option. +The message that will be shown if the underlying value's length is more +than the `max`_ option. exactMessage ~~~~~~~~~~~~ diff --git a/reference/constraints/LessThan.rst b/reference/constraints/LessThan.rst index 010ba49f9be..84dad8a0c8a 100644 --- a/reference/constraints/LessThan.rst +++ b/reference/constraints/LessThan.rst @@ -4,8 +4,8 @@ LessThan .. versionadded:: 2.3 The ``LessThan`` constraint was introduced in Symfony 2.3. -Validates that a value is less than another value, defined in the options. To -force that a value is less than or equal to another value, see +Validates that a value is less than another value, defined in the options. +To force that a value is less than or equal to another value, see :doc:`/reference/constraints/LessThanOrEqual`. To force a value is greater than another value, see :doc:`/reference/constraints/GreaterThan`. diff --git a/reference/constraints/LessThanOrEqual.rst b/reference/constraints/LessThanOrEqual.rst index 363742c95c5..294d77aa0a2 100644 --- a/reference/constraints/LessThanOrEqual.rst +++ b/reference/constraints/LessThanOrEqual.rst @@ -4,8 +4,8 @@ LessThanOrEqual .. versionadded:: 2.3 The ``LessThanOrEqual`` constraint was introduced in Symfony 2.3. -Validates that a value is less than or equal to another value, defined in the -options. To force that a value is less than another value, see +Validates that a value is less than or equal to another value, defined in +the options. To force that a value is less than another value, see :doc:`/reference/constraints/LessThan`. +----------------+-------------------------------------------------------------------------------+ @@ -22,8 +22,8 @@ options. To force that a value is less than another value, see Basic Usage ----------- -If you want to ensure that the ``age`` of a ``Person`` class is less than or -equal to ``80``, you could do the following: +If you want to ensure that the ``age`` of a ``Person`` class is less than +or equal to ``80``, you could do the following: .. configuration-block:: @@ -98,5 +98,5 @@ message **type**: ``string`` **default**: ``This value should be less than or equal to {{ compared_value }}.`` -This is the message that will be shown if the value is not less than or equal -to the comparison value. +This is the message that will be shown if the value is not less than or +equal to the comparison value. diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index 8a87d7bb461..65cf3c50192 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -3,9 +3,10 @@ Locale Validates that a value is a valid locale. -The "value" for each locale is either the two letter `ISO 639-1`_ *language* code -(e.g. ``fr``), or the language code followed by an underscore (``_``), then -the `ISO 3166-1 alpha-2`_ *country* code (e.g. ``fr_FR`` for French/France). +The "value" for each locale is either the two letter `ISO 639-1`_ *language* +code (e.g. ``fr``), or the language code followed by an underscore (``_``), +then the `ISO 3166-1 alpha-2`_ *country* code (e.g. ``fr_FR`` for +French/France). +----------------+------------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | diff --git a/reference/constraints/Luhn.rst b/reference/constraints/Luhn.rst index 637f925914f..764774cda42 100644 --- a/reference/constraints/Luhn.rst +++ b/reference/constraints/Luhn.rst @@ -4,9 +4,9 @@ Luhn .. versionadded:: 2.2 The ``Luhn`` constraint was introduced in Symfony 2.2. -This constraint is used to ensure that a credit card number passes the `Luhn algorithm`_. -It is useful as a first step to validating a credit card: before communicating with a -payment gateway. +This constraint is used to ensure that a credit card number passes the +`Luhn algorithm`_. It is useful as a first step to validating a credit +card: before communicating with a payment gateway. +----------------+-----------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index 1dbfa60d853..b1304e4ba3f 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -2,8 +2,8 @@ NotBlank ======== Validates that a value is not blank, defined as not equal to a blank string -and also not equal to ``null``. To force that a value is simply not equal to -``null``, see the :doc:`/reference/constraints/NotNull` constraint. +and also not equal to ``null``. To force that a value is simply not equal +to ``null``, see the :doc:`/reference/constraints/NotNull` constraint. +----------------+------------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | @@ -18,8 +18,8 @@ and also not equal to ``null``. To force that a value is simply not equal to Basic Usage ----------- -If you wanted to ensure that the ``firstName`` property of an ``Author`` class -were not blank, you could do the following: +If you wanted to ensure that the ``firstName`` property of an ``Author`` +class were not blank, you could do the following: .. configuration-block:: diff --git a/reference/constraints/NotEqualTo.rst b/reference/constraints/NotEqualTo.rst index 211b88df865..a816514d8c8 100644 --- a/reference/constraints/NotEqualTo.rst +++ b/reference/constraints/NotEqualTo.rst @@ -28,8 +28,8 @@ options. To force that a value is equal, see Basic Usage ----------- -If you want to ensure that the ``age`` of a ``Person`` class is not equal to -``15``, you could do the following: +If you want to ensure that the ``age`` of a ``Person`` class is not equal +to ``15``, you could do the following: .. configuration-block:: diff --git a/reference/constraints/NotIdenticalTo.rst b/reference/constraints/NotIdenticalTo.rst index 7633e1fec61..5c59ce38981 100644 --- a/reference/constraints/NotIdenticalTo.rst +++ b/reference/constraints/NotIdenticalTo.rst @@ -4,15 +4,15 @@ NotIdenticalTo .. versionadded:: 2.3 The ``NotIdenticalTo`` constraint was introduced in Symfony 2.3. -Validates that a value is **not** identical to another value, defined in the -options. To force that a value is identical, see +Validates that a value is **not** identical to another value, defined in +the 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 ``!=``. + considered not equal. Use :doc:`/reference/constraints/NotEqualTo` to + compare with ``!=``. +----------------+-----------------------------------------------------------------------------+ | Applies to | :ref:`property or method` | @@ -28,8 +28,8 @@ options. To force that a value is identical, see Basic Usage ----------- -If you want to ensure that the ``age`` of a ``Person`` class is *not* equal to -``15`` and *not* an integer, you could do the following: +If you want to ensure that the ``age`` of a ``Person`` class is *not* equal +to ``15`` and *not* an integer, you could do the following: .. configuration-block:: diff --git a/reference/constraints/NotNull.rst b/reference/constraints/NotNull.rst index 333481f49e4..462e7035ab3 100644 --- a/reference/constraints/NotNull.rst +++ b/reference/constraints/NotNull.rst @@ -18,8 +18,8 @@ constraint. Basic Usage ----------- -If you wanted to ensure that the ``firstName`` property of an ``Author`` class -were not strictly equal to ``null``, you would: +If you wanted to ensure that the ``firstName`` property of an ``Author`` +class were not strictly equal to ``null``, you would: .. configuration-block:: diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index 92cefbd80b6..b38f1d1c8f7 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -20,8 +20,8 @@ Validates that a given number is *between* some minimum and maximum number. Basic Usage ----------- -To verify that the "height" field of a class is between "120" and "180", you might add -the following: +To verify that the "height" field of a class is between "120" and "180", +you might add the following: .. configuration-block:: @@ -122,16 +122,16 @@ minMessage **type**: ``string`` **default**: ``This value should be {{ limit }} or more.`` -The message that will be shown if the underlying value is less than the `min`_ -option. +The message that will be shown if the underlying value is less than the +`min`_ option. maxMessage ~~~~~~~~~~ **type**: ``string`` **default**: ``This value should be {{ limit }} or less.`` -The message that will be shown if the underlying value is more than the `max`_ -option. +The message that will be shown if the underlying value is more than the +`max`_ option. invalidMessage ~~~~~~~~~~~~~~ diff --git a/reference/constraints/Regex.rst b/reference/constraints/Regex.rst index 05f3e130b8b..cff63414c0b 100644 --- a/reference/constraints/Regex.rst +++ b/reference/constraints/Regex.rst @@ -19,10 +19,10 @@ Validates that a value matches a regular expression. Basic Usage ----------- -Suppose you have a ``description`` field and you want to verify that it begins -with a valid word character. The regular expression to test for this would -be ``/^\w+/``, indicating that you're looking for at least one or more word -characters at the beginning of your string: +Suppose you have a ``description`` field and you want to verify that it +begins with a valid word character. The regular expression to test for this +would be ``/^\w+/``, indicating that you're looking for at least one or +more word characters at the beginning of your string: .. configuration-block:: @@ -84,10 +84,10 @@ characters at the beginning of your string: } } -Alternatively, you can set the `match`_ option to ``false`` in order to assert -that a given string does *not* match. In the following example, you'll assert -that the ``firstName`` field does not contain any numbers and give it a custom -message: +Alternatively, you can set the `match`_ option to ``false`` in order to +assert that a given string does *not* match. In the following example, you'll +assert that the ``firstName`` field does not contain any numbers and give +it a custom message: .. configuration-block:: @@ -170,9 +170,9 @@ pattern This required option is the regular expression pattern that the input will be matched against. By default, this validator will fail if the input string -does *not* match this regular expression (via the :phpfunction:`preg_match` PHP function). -However, if `match`_ is set to false, then validation will fail if the input -string *does* match this pattern. +does *not* match this regular expression (via the :phpfunction:`preg_match` +PHP function). However, if `match`_ is set to false, then validation will +fail if the input string *does* match this pattern. htmlPattern ~~~~~~~~~~~ @@ -185,12 +185,13 @@ htmlPattern This option specifies the pattern to use in the HTML5 ``pattern`` attribute. You usually don't need to specify this option because by default, the constraint will convert the pattern given in the `pattern`_ option into an HTML5 compatible -pattern. This means that the delimiters are removed (e.g. ``/[a-z]+/`` becomes ``[a-z]+``). +pattern. This means that the delimiters are removed (e.g. ``/[a-z]+/`` becomes +``[a-z]+``). 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:: @@ -268,8 +269,8 @@ match If ``true`` (or not set), this validator will pass if the given string matches the given `pattern`_ regular expression. However, when this option is set -to ``false``, the opposite will occur: validation will pass only if the given -string does **not** match the `pattern`_ regular expression. +to ``false``, the opposite will occur: validation will pass only if the +given string does **not** match the `pattern`_ regular expression. message ~~~~~~~ diff --git a/reference/constraints/True.rst b/reference/constraints/True.rst index f81cbec1073..b54338a973d 100644 --- a/reference/constraints/True.rst +++ b/reference/constraints/True.rst @@ -21,11 +21,9 @@ Basic Usage ----------- This constraint can be applied to properties (e.g. a ``termsAccepted`` property -on a registration model) or to a "getter" method. It's most powerful in the -latter case, where you can assert that a method returns a true value. For -example, suppose you have the following method: - -.. code-block:: php +on a registration model) or to a "getter" method. It's most powerful in +the latter case, where you can assert that a method returns a true value. +For example, suppose you have the following method:: // src/Acme/BlogBundle/Entity/Author.php namespace Acme\BlogBundle\Entity; diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index b9323e38a93..1ce510b1136 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -2,8 +2,8 @@ Type ==== Validates that a value is of a specific data type. For example, if a variable -should be an array, you can use this constraint with the ``array`` type option -to validate this. +should be an array, you can use this constraint with the ``array`` type +option to validate this. +----------------+---------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | @@ -31,7 +31,10 @@ Basic Usage class Author { /** - * @Assert\Type(type="integer", message="The value {{ value }} is not a valid {{ type }}.") + * @Assert\Type( + * type="integer", + * message="The value {{ value }} is not a valid {{ type }}." + * ) */ protected $age; } @@ -93,8 +96,8 @@ type **type**: ``string`` [:ref:`default option `] -This required option is the fully qualified class name or one of the PHP datatypes -as determined by PHP's ``is_`` functions. +This required option is the fully qualified class name or one of the PHP +datatypes as determined by PHP's ``is_`` functions. * :phpfunction:`array ` * :phpfunction:`bool ` @@ -112,8 +115,9 @@ as determined by PHP's ``is_`` functions. * :phpfunction:`scalar ` * :phpfunction:`string ` -Also, you can use ``ctype_`` functions from corresponding `built-in PHP extension `_. -Consider `a list of ctype functions `_: +Also, you can use ``ctype_`` functions from corresponding +`built-in PHP extension `_. Consider +`a list of ctype functions `_: * :phpfunction:`alnum ` * :phpfunction:`alpha ` @@ -127,7 +131,8 @@ Consider `a list of ctype functions `_: * :phpfunction:`upper ` * :phpfunction:`xdigit ` -Make sure that the proper :phpfunction:`locale ` is set before using one of these. +Make sure that the proper :phpfunction:`locale ` is set before +using one of these. message ~~~~~~~ diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index ab2c5f8c85c..457c60c9f81 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -23,10 +23,10 @@ using an email address that already exists in the system. Basic Usage ----------- -Suppose you have an AcmeUserBundle bundle with a ``User`` entity that has an -``email`` field. You can use the ``UniqueEntity`` constraint to guarantee that -the ``email`` field remains unique between all of the constraints in your user -table: +Suppose you have an AcmeUserBundle bundle with a ``User`` entity that has +an ``email`` field. You can use the ``UniqueEntity`` constraint to guarantee +that the ``email`` field remains unique between all of the constraints in +your user table: .. configuration-block:: @@ -139,19 +139,19 @@ em **type**: ``string`` -The name of the entity manager to use for making the query to determine the -uniqueness. If it's left blank, the correct entity manager will be determined -for this class. For that reason, this option should probably not need to be -used. +The name of the entity manager to use for making the query to determine +the uniqueness. If it's left blank, the correct entity manager will be +determined for this class. For that reason, this option should probably +not need to be used. repositoryMethod ~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``findBy`` -The name of the repository method to use for making the query to determine the -uniqueness. If it's left blank, the ``findBy`` method will be used. This -method should return a countable result. +The name of the repository method to use for making the query to determine +the uniqueness. If it's left blank, the ``findBy`` method will be used. +This method should return a countable result. errorPath ~~~~~~~~~ @@ -161,9 +161,9 @@ errorPath .. versionadded:: 2.1 The ``errorPath`` option was introduced in Symfony 2.1. -If the entity violates the constraint the error message is bound to the first -field in `fields`_. If there is more than one field, you may want to map -the error message to another field. +If the entity violates the constraint the error message is bound to the +first field in `fields`_. If there is more than one field, you may want +to map the error message to another field. Consider this example: diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index bd9945346be..26715d55c02 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -90,4 +90,4 @@ protocols The protocols that will be considered to be valid. For example, if you also needed ``ftp://`` type URLs to be valid, you'd redefine the ``protocols`` -array, listing ``http``, ``https``, and also ``ftp``. +array, listing ``http``, ``https`` and also ``ftp``. diff --git a/reference/constraints/UserPassword.rst b/reference/constraints/UserPassword.rst index 75a9cc11b22..546b68261db 100644 --- a/reference/constraints/UserPassword.rst +++ b/reference/constraints/UserPassword.rst @@ -5,19 +5,19 @@ UserPassword Since Symfony 2.2, the ``UserPassword*`` classes in the :namespace:`Symfony\\Component\\Security\\Core\\Validator\\Constraint ` - namespace are deprecated and will be removed in Symfony 2.3. Please use - the ``UserPassword*`` classes in the + namespace are deprecated and will be removed in Symfony 2.3. Please + use the ``UserPassword*`` classes in the :namespace:`Symfony\\Component\\Security\\Core\\Validator\\Constraints ` namespace instead. This validates that an input value is equal to the current authenticated -user's password. This is useful in a form where a user can change their password, -but needs to enter their old password for security. +user's password. This is useful in a form where a user can change their +password, but needs to enter their old password for security. .. note:: - This should **not** be used to validate a login form, since this is done - automatically by the security system. + This should **not** be used to validate a login form, since this is + done automatically by the security system. +----------------+--------------------------------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | @@ -32,10 +32,10 @@ but needs to enter their old password for security. Basic Usage ----------- -Suppose you have a `PasswordChange` class, that's used in a form where the -user can change their password by entering their old password and a new password. -This constraint will validate that the old password matches the user's current -password: +Suppose you have a ``PasswordChange`` class, that's used in a form where +the user can change their password by entering their old password and a +new password. This constraint will validate that the old password matches +the user's current password: .. configuration-block:: @@ -75,7 +75,9 @@ password: - + @@ -94,9 +96,12 @@ password: { public static function loadValidatorData(ClassMetadata $metadata) { - $metadata->addPropertyConstraint('oldPassword', new SecurityAssert\UserPassword(array( - 'message' => 'Wrong value for your current password', - ))); + $metadata->addPropertyConstraint( + 'oldPassword', + new SecurityAssert\UserPassword(array( + 'message' => 'Wrong value for your current password', + )) + ); } } diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index 92c0421c03d..03a95ca6ff0 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -2,8 +2,8 @@ Valid ===== This constraint is used to enable validation on objects that are embedded -as properties on an object being validated. This allows you to validate an -object and all sub-objects associated with it. +as properties on an object being validated. This allows you to validate +an object and all sub-objects associated with it. +----------------+---------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | @@ -20,8 +20,8 @@ Basic Usage ----------- In the following example, create two classes ``Author`` and ``Address`` -that both have constraints on their properties. Furthermore, ``Author`` stores -an ``Address`` instance in the ``$address`` property. +that both have constraints on their properties. Furthermore, ``Author`` +stores an ``Address`` instance in the ``$address`` property. .. code-block:: php @@ -185,9 +185,9 @@ an ``Address`` instance in the ``$address`` property. } } -With this mapping, it is possible to successfully validate an author with an -invalid address. To prevent that, add the ``Valid`` constraint to the ``$address`` -property. +With this mapping, it is possible to successfully validate an author with +an invalid address. To prevent that, add the ``Valid`` constraint to the +``$address`` property. .. configuration-block:: @@ -247,8 +247,8 @@ property. } } -If you validate an author with an invalid address now, you can see that the -validation of the ``Address`` fields failed. +If you validate an author with an invalid address now, you can see that +the validation of the ``Address`` fields failed. .. code-block:: text @@ -264,8 +264,8 @@ traverse **type**: ``boolean`` **default**: ``true`` If this constraint is applied to a property that holds an array of objects, -then each object in that array will be validated only if this option is set -to ``true``. +then each object in that array will be validated only if this option is +set to ``true``. deep ~~~~ @@ -273,5 +273,5 @@ deep **type**: ``boolean`` **default**: ``false`` If this constraint is applied to a property that holds an array of objects, -then each object in that array will be validated recursively if this option is set -to ``true``. +then each object in that array will be validated recursively if this option +is set to ``true``. diff --git a/reference/constraints/_comparison-value-option.rst.inc b/reference/constraints/_comparison-value-option.rst.inc index 4b24250cec5..cb7e07045a5 100644 --- a/reference/constraints/_comparison-value-option.rst.inc +++ b/reference/constraints/_comparison-value-option.rst.inc @@ -1,7 +1,7 @@ value ~~~~~ -**type**: ``mixed`` [:ref:`default option`] +**type**: ``mixed`` [:ref:`default option `] This option is required. It defines the value to compare to. It can be a string, number or object. From 08178a566f214eb7e41bfd698b26ca06dac8d8eb Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 16 May 2015 11:15:47 +0200 Subject: [PATCH 2/2] Review other reference articles --- reference/dic_tags.rst | 167 ++++++++++++++++++++--------------- reference/requirements.rst | 10 +-- reference/twig_reference.rst | 72 +++++++-------- 3 files changed, 139 insertions(+), 110 deletions(-) diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index bdce845b312..72488dcb85c 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -2,9 +2,9 @@ The Dependency Injection Tags ============================= Dependency Injection Tags are little strings that can be applied to a service -to "flag" it to be used in some special way. For example, if you have a service -that you would like to register as a listener to one of Symfony's core events, -you can flag it with the ``kernel.event_listener`` tag. +to "flag" it to be used in some special way. For example, if you have a +service that you would like to register as a listener to one of Symfony's +core events, you can flag it with the ``kernel.event_listener`` tag. You can learn a little bit more about "tags" by reading the ":ref:`book-service-container-tags`" section of the Service Container chapter. @@ -296,12 +296,13 @@ form.type_extension **Purpose**: Create a custom "form extension" -Form type extensions are a way for you took "hook into" the creation of any -field in your form. For example, the addition of the CSRF token is done via -a form type extension (:class:`Symfony\\Component\\Form\\Extension\\Csrf\\Type\\FormTypeCsrfExtension`). +Form type extensions are a way for you took "hook into" the creation of +any field in your form. For example, the addition of the CSRF token is done +via a form type extension +(:class:`Symfony\\Component\\Form\\Extension\\Csrf\\Type\\FormTypeCsrfExtension`). -A form type extension can modify any part of any field in your form. To create -a form type extension, first create a class that implements the +A form type extension can modify any part of any field in your form. To +create a form type extension, first create a class that implements the :class:`Symfony\\Component\\Form\\FormTypeExtensionInterface` interface. For simplicity, you'll often extend an :class:`Symfony\\Component\\Form\\AbstractTypeExtension` class instead of @@ -318,8 +319,8 @@ the interface directly:: // like buildForm(), buildView(), finishView(), setDefaultOptions() } -In order for Symfony to know about your form extension and use it, give it -the ``form.type_extension`` tag: +In order for Symfony to know about your form extension and use it, give +it the ``form.type_extension`` tag: .. configuration-block:: @@ -351,13 +352,16 @@ the ``form.type_extension`` tag: .. code-block:: php $container - ->register('main.form.type.my_form_type_extension', 'Acme\MainBundle\Form\Type\MyFormTypeExtension') + ->register( + 'main.form.type.my_form_type_extension', + 'Acme\MainBundle\Form\Type\MyFormTypeExtension' + ) ->addTag('form.type_extension', array('alias' => 'field')) ; The ``alias`` key of the tag is the type of field that this extension should -be applied to. For example, to apply the extension to any form/field, use the -"form" value. +be applied to. For example, to apply the extension to any form/field, use +the "form" value. .. _reference-dic-type_guesser: @@ -379,7 +383,8 @@ metadata and Doctrine metadata (if you're using Doctrine) or Propel metadata kernel.cache_clearer -------------------- -**Purpose**: Register your service to be called during the cache clearing process +**Purpose**: Register your service to be called during the cache clearing +process Cache clearing occurs whenever you call ``cache:clear`` command. If your bundle caches files, you should add custom cache clearer for clearing those @@ -438,14 +443,15 @@ Then register this class and tag it with ``kernel.cache_clearer``: kernel.cache_warmer ------------------- -**Purpose**: Register your service to be called during the cache warming process +**Purpose**: Register your service to be called during the cache warming +process Cache warming occurs whenever you run the ``cache:warmup`` or ``cache:clear`` -task (unless you pass ``--no-warmup`` to ``cache:clear``). It is also run when -handling the request, if it wasn't done by one of the commands yet. The purpose is -to initialize any cache that will be needed by the application and prevent -the first user from any significant "cache hit" where the cache is generated -dynamically. +task (unless you pass ``--no-warmup`` to ``cache:clear``). It is also run +when handling the request, if it wasn't done by one of the commands yet. +The purpose is to initialize any cache that will be needed by the application +and prevent the first user from any significant "cache hit" where the cache +is generated dynamically. To register your own cache warmer, first create a service that implements the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` interface:: @@ -473,7 +479,8 @@ application without calling this cache warmer. In Symfony, optional warmers are always executed by default (you can change this by using the ``--no-optional-warmers`` option when executing the command). -To register your warmer with Symfony, give it the ``kernel.cache_warmer`` tag: +To register your warmer with Symfony, give it the ``kernel.cache_warmer`` +tag: .. configuration-block:: @@ -493,7 +500,9 @@ To register your warmer with Symfony, give it the ``kernel.cache_warmer`` tag: xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + @@ -508,8 +517,8 @@ To register your warmer with Symfony, give it the ``kernel.cache_warmer`` tag: .. note:: - The ``priority`` value is optional, and defaults to 0. - The higher the priority, the sooner it gets executed. + The ``priority`` value is optional and defaults to 0. The higher the + priority, the sooner it gets executed. Core Cache Warmers ~~~~~~~~~~~~~~~~~~ @@ -629,7 +638,7 @@ kernel.event_subscriber **Purpose**: To subscribe to a set of different events/hooks in Symfony To enable a custom subscriber, add it as a regular service in one of your -configuration, and tag it with ``kernel.event_subscriber``: +configuration and tag it with ``kernel.event_subscriber``: .. configuration-block:: @@ -661,7 +670,10 @@ configuration, and tag it with ``kernel.event_subscriber``: .. code-block:: php $container - ->register('kernel.subscriber.your_subscriber_name', 'Fully\Qualified\Subscriber\Class\Name') + ->register( + 'kernel.subscriber.your_subscriber_name', + 'Fully\Qualified\Subscriber\Class\Name' + ) ->addTag('kernel.event_subscriber') ; @@ -672,8 +684,8 @@ configuration, and tag it with ``kernel.event_subscriber``: .. note:: - If your service is created by a factory, you **MUST** correctly set the ``class`` - parameter for this tag to work correctly. + If your service is created by a factory, you **MUST** correctly set + the ``class`` parameter for this tag to work correctly. kernel.fragment_renderer ------------------------ @@ -724,7 +736,9 @@ channel when injecting the logger in a service. .. code-block:: php - $definition = new Definition('Fully\Qualified\Loader\Class\Name', array(new Reference('logger')); + $definition = new Definition('Fully\Qualified\Loader\Class\Name', array( + new Reference('logger'), + )); $definition->addTag('monolog.logger', array('channel' => 'acme')); $container->setDefinition('my_service', $definition); @@ -741,13 +755,13 @@ monolog.processor **Purpose**: Add a custom processor for logging -Monolog allows you to add processors in the logger or in the handlers to add -extra data in the records. A processor receives the record as an argument and -must return it after adding some extra data in the ``extra`` attribute of -the record. +Monolog allows you to add processors in the logger or in the handlers to +add extra data in the records. A processor receives the record as an argument +and must return it after adding some extra data in the ``extra`` attribute +of the record. -The built-in ``IntrospectionProcessor`` can be used to add the file, the line, -the class and the method where the logger was triggered. +The built-in ``IntrospectionProcessor`` can be used to add the file, the +line, the class and the method where the logger was triggered. You can add a processor globally: @@ -821,9 +835,9 @@ attribute: ->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 -channel used in the Security component: +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 channel used in the Security component: .. configuration-block:: @@ -867,7 +881,7 @@ routing.loader **Purpose**: Register a custom service that loads routes To enable a custom routing loader, add it as a regular service in one -of your configuration, and tag it with ``routing.loader``: +of your configuration and tag it with ``routing.loader``: .. configuration-block:: @@ -910,9 +924,9 @@ security.remember_me_aware **Purpose**: To allow remember me authentication -This tag is used internally to allow remember-me authentication to work. If -you have a custom authentication method where a user can be remember-me authenticated, -then you may need to use this tag. +This tag is used internally to allow remember-me authentication to work. +If you have a custom authentication method where a user can be remember-me +authenticated, then you may need to use this tag. If your custom authentication factory extends :class:`Symfony\\Bundle\\SecurityBundle\\DependencyInjection\\Security\\Factory\\AbstractFactory` @@ -961,15 +975,16 @@ swiftmailer.default.plugin **Purpose**: Register a custom SwiftMailer Plugin -If you're using a custom SwiftMailer plugin (or want to create one), you can -register it with SwiftMailer by creating a service for your plugin and tagging -it with ``swiftmailer.default.plugin`` (it has no options). +If you're using a custom SwiftMailer plugin (or want to create one), you +can register it with SwiftMailer by creating a service for your plugin and +tagging it with ``swiftmailer.default.plugin`` (it has no options). .. note:: ``default`` in this tag is the name of the mailer. If you have multiple - mailers configured or have changed the default mailer name for some reason, - you should change it to the name of your mailer in order to use this tag. + mailers configured or have changed the default mailer name for some + reason, you should change it to the name of your mailer in order to + use this tag. A SwiftMailer plugin must implement the ``Swift_Events_EventListener`` interface. For more information on plugins, see `SwiftMailer's Plugin Documentation`_. @@ -1028,8 +1043,8 @@ translation.loader **Purpose**: To register a custom service that loads translations -By default, translations are loaded from the filesystem in a variety of different -formats (YAML, XLIFF, PHP, etc). +By default, translations are loaded from the filesystem in a variety of +different formats (YAML, XLIFF, PHP, etc). .. seealso:: @@ -1068,19 +1083,23 @@ Now, register your loader as a service and tag it with ``translation.loader``: .. code-block:: php $container - ->register('main.translation.my_custom_loader', 'Acme\MainBundle\Translation\MyCustomLoader') + ->register( + 'main.translation.my_custom_loader', + 'Acme\MainBundle\Translation\MyCustomLoader' + ) ->addTag('translation.loader', array('alias' => 'bin')) ; The ``alias`` option is required and very important: it defines the file -"suffix" that will be used for the resource files that use this loader. For -example, suppose you have some custom ``bin`` format that you need to load. -If you have a ``bin`` file that contains French translations for the ``messages`` -domain, then you might have a file ``app/Resources/translations/messages.fr.bin``. +"suffix" that will be used for the resource files that use this loader. +For example, suppose you have some custom ``bin`` format that you need to +load. If you have a ``bin`` file that contains French translations for +the ``messages`` domain, then you might have a file +``app/Resources/translations/messages.fr.bin``. -When Symfony tries to load the ``bin`` file, it passes the path to your custom -loader as the ``$resource`` argument. You can then perform any logic you need -on that file in order to load your translations. +When Symfony tries to load the ``bin`` file, it passes the path to your +custom loader as the ``$resource`` argument. You can then perform any logic +you need on that file in order to load your translations. If you're loading translations from a database, you'll still need a resource file, but it might either be blank or contain a little bit of information @@ -1090,7 +1109,8 @@ the ``load`` method on your custom loader. translation.extractor --------------------- -**Purpose**: To register a custom service that extracts messages from a file +**Purpose**: To register a custom service that extracts messages from a +file .. versionadded:: 2.1 The ability to add message extractors was introduced in Symfony 2.1. @@ -1102,9 +1122,9 @@ has a :class:`Symfony\\Bridge\\Twig\\Translation\\TwigExtractor` and a help to find and extract translation keys from Twig templates and PHP files. You can create your own extractor by creating a class that implements -:class:`Symfony\\Component\\Translation\\Extractor\\ExtractorInterface` and -tagging the service with ``translation.extractor``. The tag has one required -option: ``alias``, which defines the name of the extractor:: +:class:`Symfony\\Component\\Translation\\Extractor\\ExtractorInterface` +and tagging the service with ``translation.extractor``. The tag has one +required option: ``alias``, which defines the name of the extractor:: // src/Acme/DemoBundle/Translation/FooExtractor.php namespace Acme\DemoBundle\Translation; @@ -1176,9 +1196,9 @@ translation.dumper .. versionadded:: 2.1 The ability to add message dumpers was introduced in Symfony 2.1. -After an `Extractor `_ has extracted all messages from -the templates, the dumpers are executed to dump the messages to a translation -file in a specific format. +After an `Extractor `_ has extracted all messages +from the templates, the dumpers are executed to dump the messages to a +translation file in a specific format. Symfony already comes with many dumpers: @@ -1245,7 +1265,7 @@ twig.extension **Purpose**: To register a custom Twig Extension To enable a Twig extension, add it as a regular service in one of your -configuration, and tag it with ``twig.extension``: +configuration and tag it with ``twig.extension``: .. configuration-block:: @@ -1277,7 +1297,10 @@ configuration, and tag it with ``twig.extension``: .. code-block:: php $container - ->register('twig.extension.your_extension_name', 'Fully\Qualified\Extension\Class\Name') + ->register( + 'twig.extension.your_extension_name', + 'Fully\Qualified\Extension\Class\Name' + ) ->addTag('twig.extension') ; @@ -1362,7 +1385,10 @@ the new loader and tag it with ``twig.loader``: .. code-block:: php $container - ->register('acme.demo_bundle.loader.some_twig_loader', 'Acme\DemoBundle\Loader\SomeTwigLoader') + ->register( + 'acme.demo_bundle.loader.some_twig_loader', + 'Acme\DemoBundle\Loader\SomeTwigLoader' + ) ->addTag('twig.loader') ; @@ -1383,14 +1409,15 @@ This tag provides a very uncommon piece of functionality that allows you to perform some sort of action on an object right before it's validated. For example, it's used by Doctrine to query for all of the lazily-loaded data on an object before it's validated. Without this, some data on a Doctrine -entity would appear to be "missing" when validated, even though this is not -really the case. +entity would appear to be "missing" when validated, even though this is +not really the case. If you do need to use this tag, just make a new class that implements the :class:`Symfony\\Component\\Validator\\ObjectInitializerInterface` interface. Then, tag it with the ``validator.initializer`` tag (it has no options). -For an example, see the ``EntityInitializer`` class inside the Doctrine Bridge. +For an example, see the ``EntityInitializer`` class inside the Doctrine +Bridge. .. _`Twig's documentation`: http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension .. _`Twig official extension repository`: https://github.com/twigphp/Twig-extensions diff --git a/reference/requirements.rst b/reference/requirements.rst index 5edc791f788..959005abc1c 100644 --- a/reference/requirements.rst +++ b/reference/requirements.rst @@ -6,11 +6,11 @@ Requirements for Running Symfony ================================ -To run Symfony, your system needs to adhere to a list of requirements. You can -easily see if your system passes all requirements by running the ``web/config.php`` -in your Symfony distribution. Since the CLI often uses a different ``php.ini`` -configuration file, it's also a good idea to check your requirements from -the command line via: +To run Symfony, your system needs to adhere to a list of requirements. You +can easily see if your system passes all requirements by running the +``web/config.php`` in your Symfony distribution. Since the CLI often uses +a different ``php.ini`` configuration file, it's also a good idea to check +your requirements from the command line via: .. code-block:: bash diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 9298ef46c8a..d900016c1b8 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -96,8 +96,8 @@ controller ``query`` **type**: ``array`` **default**: ``[]`` -Returns an instance of ``ControllerReference`` to be used with functions like -:ref:`render() ` and +Returns an instance of ``ControllerReference`` to be used with functions +like :ref:`render() ` and :ref:`render_esi() `. asset @@ -112,8 +112,8 @@ asset ``packageName`` **type**: ``string`` | ``null`` **default**: ``null`` -Returns a public path to ``path``, which takes into account the base path set -for the package and the URL path. More information in +Returns a public path to ``path``, which takes into account the base path +set for the package and the URL path. More information in :ref:`book-templating-assets`. assets_version @@ -171,8 +171,9 @@ form_end ``variables`` **type**: ``array`` **default**: ``[]`` -Renders the HTML end tag of a form together with all fields that have not been -rendered yet, more information in :ref:`the Twig Form reference `. +Renders the HTML end tag of a form together with all fields that have not +been rendered yet, more information in +:ref:`the Twig Form reference `. form_enctype ~~~~~~~~~~~~ @@ -184,8 +185,8 @@ form_enctype ``view`` **type**: ``FormView`` -Renders the required ``enctype="multipart/form-data"`` attribute if the form -contains at least one file upload field, more information in +Renders the required ``enctype="multipart/form-data"`` attribute if the +form contains at least one file upload field, more information in :ref:`the Twig Form reference `. form_widget @@ -245,8 +246,8 @@ form_row ``variables`` **type**: ``array`` **default**: ``[]`` -Renders the row (the field's label, errors and widget) of the given field, more -information in :ref:`the Twig Form reference `. +Renders the row (the field's label, errors and widget) of the given field, +more information in :ref:`the Twig Form reference `. form_rest ~~~~~~~~~ @@ -290,15 +291,14 @@ is_granted ``field`` **type**: ``string`` -Returns ``true`` if the current user has the required role. Optionally, an -object can be pasted to be used by the voter. More information can be found in -:ref:`book-security-template`. +Returns ``true`` if the current user has the required role. Optionally, +an object can be pasted to be used by the voter. More information can be +found in :ref:`book-security-template`. .. note:: - You can also pass in the field to use ACE for a specific field. Read more - about this in :ref:`cookbook-security-acl-field_scope`. - + You can also pass in the field to use ACE for a specific field. Read + more about this in :ref:`cookbook-security-acl-field_scope`. logout_path ~~~~~~~~~~~ @@ -339,9 +339,9 @@ path ``relative`` **type**: ``boolean`` **default**: ``false`` -Returns the relative URL (without the scheme and host) for the given route. If -``relative`` is enabled, it'll create a path relative to the current path. More -information in :ref:`book-templating-pages`. +Returns the relative URL (without the scheme and host) for the given route. +If ``relative`` is enabled, it'll create a path relative to the current +path. More information in :ref:`book-templating-pages`. url ~~~ @@ -379,8 +379,8 @@ humanize ``text`` **type**: ``string`` -Makes a technical name human readable (i.e. replaces underscores by spaces and -capitalizes the string). +Makes a technical name human readable (i.e. replaces underscores by spaces +and capitalizes the string). trans ~~~~~ @@ -436,8 +436,8 @@ yaml_encode ``dumpObjects`` **type**: ``boolean`` **default**: ``false`` -Transforms the input into YAML syntax. See :ref:`components-yaml-dump` for more -information. +Transforms the input into YAML syntax. See :ref:`components-yaml-dump` for +more information. yaml_dump ~~~~~~~~~ @@ -453,7 +453,8 @@ yaml_dump ``dumpObjects`` **type**: ``boolean`` **default**: ``false`` -Does the same as `yaml_encode() `_, but includes the type in the output. +Does the same as `yaml_encode() `_, but includes the type in +the output. abbr_class ~~~~~~~~~~ @@ -465,8 +466,8 @@ abbr_class ``class`` **type**: ``string`` -Generates an ```` element with the short name of a PHP class (the FQCN -will be shown in a tooltip when a user hovers over the element). +Generates an ```` element with the short name of a PHP class (the +FQCN will be shown in a tooltip when a user hovers over the element). abbr_method ~~~~~~~~~~~ @@ -478,9 +479,9 @@ abbr_method ``method`` **type**: ``string`` -Generates an ```` element using the ``FQCN::method()`` syntax. If ``method`` -is ``Closure``, ``Closure`` will be used instead and if ``method`` doesn't have a -class name, it's shown as a function (``method()``). +Generates an ```` element using the ``FQCN::method()`` syntax. If +``method`` is ``Closure``, ``Closure`` will be used instead and if ``method`` +doesn't have a class name, it's shown as a function (``method()``). format_args ~~~~~~~~~~~ @@ -534,8 +535,8 @@ format_file ``text`` **type**: ``string`` **default**: ``null`` -Generates the file path inside an ```` element. If the path is inside the -kernel root directory, the kernel root directory path is replaced by +Generates the file path inside an ```` element. If the path is inside +the kernel root directory, the kernel root directory path is replaced by ``kernel.root_dir`` (showing the full path in a tooltip on hover). format_file_from_text @@ -560,8 +561,8 @@ file_link ``line`` **type**: ``integer`` -Generates a link to the provided file (and optionally line number) using a -preconfigured scheme. +Generates a link to the provided file (and optionally line number) using +a preconfigured scheme. .. _reference-twig-tags: @@ -678,8 +679,9 @@ Symfony Standard Edition Extensions The Symfony Standard Edition adds some bundles to the Symfony Core Framework. Those bundles can have other Twig extensions: -* **Twig Extensions** includes some interesting extensions that do not belong to the - Twig core. You can read more in `the official Twig Extensions documentation`_; +* **Twig Extensions** includes some interesting extensions that do not belong + to the Twig core. You can read more in `the official Twig Extensions + documentation`_; * **Assetic** adds the ``{% stylesheets %}``, ``{% javascripts %}`` and ``{% image %}`` tags. You can read more about them in :doc:`the Assetic Documentation `.