Skip to content

Commit 69b52c7

Browse files
committed
Merge branch '2.4'
2 parents c8bfde6 + fed881d commit 69b52c7

File tree

4 files changed

+75
-18
lines changed

4 files changed

+75
-18
lines changed

book/validation.rst

+63-10
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,8 @@ Group Sequence
842842
--------------
843843

844844
In some cases, you want to validate your groups by steps. To do this, you can
845-
use the ``GroupSequence`` feature. In this case, an object defines a group sequence
846-
, which determines the order groups should be validated.
845+
use the ``GroupSequence`` feature. In this case, an object defines a group
846+
sequence, which determines the order groups should be validated.
847847

848848
For example, suppose you have a ``User`` class and want to validate that the
849849
username and the password are different only if all other validation passes
@@ -1085,21 +1085,14 @@ Now, change the ``User`` class to implement
10851085
:class:`Symfony\\Component\\Validator\\GroupSequenceProviderInterface` and
10861086
add the
10871087
:method:`Symfony\\Component\\Validator\\GroupSequenceProviderInterface::getGroupSequence`,
1088-
which should return an array of groups to use. Also, add the
1089-
``@Assert\GroupSequenceProvider`` annotation to the class (or ``group_sequence_provider: true`` to the YAML). If you imagine
1090-
that a method called ``isPremium`` returns true if the user is a premium member,
1091-
then your code might look like this::
1088+
which should return an array of groups to use::
10921089

10931090
// src/Acme/DemoBundle/Entity/User.php
10941091
namespace Acme\DemoBundle\Entity;
10951092

10961093
// ...
10971094
use Symfony\Component\Validator\GroupSequenceProviderInterface;
10981095

1099-
/**
1100-
* @Assert\GroupSequenceProvider
1101-
* ...
1102-
*/
11031096
class User implements GroupSequenceProviderInterface
11041097
{
11051098
// ...
@@ -1116,6 +1109,66 @@ then your code might look like this::
11161109
}
11171110
}
11181111

1112+
At last, you have to notify the Validator component that your ``User`` class
1113+
provides a sequence of groups to be validated:
1114+
1115+
.. configuration-block::
1116+
1117+
.. code-block:: yaml
1118+
1119+
# src/Acme/DemoBundle/Resources/config/validation.yml
1120+
Acme\DemoBundle\Entity\User:
1121+
group_sequence_provider: ~
1122+
1123+
.. code-block:: php-annotations
1124+
1125+
// src/Acme/DemoBundle/Entity/User.php
1126+
namespace Acme\DemoBundle\Entity;
1127+
1128+
// ...
1129+
1130+
/**
1131+
* @Assert\GroupSequenceProvider
1132+
*/
1133+
class User implements GroupSequenceProviderInterface
1134+
{
1135+
// ...
1136+
}
1137+
1138+
.. code-block:: xml
1139+
1140+
<!-- src/Acme/DemoBundle/Resources/config/validation.xml -->
1141+
<?xml version="1.0" encoding="UTF-8" ?>
1142+
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
1143+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1144+
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
1145+
http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"
1146+
>
1147+
<class name="Acme\DemoBundle\Entity\User">
1148+
<group-sequence-provider />
1149+
<!-- ... -->
1150+
</class>
1151+
</constraint-mapping>
1152+
1153+
.. code-block:: php
1154+
1155+
// src/Acme/DemoBundle/Entity/User.php
1156+
namespace Acme\DemoBundle\Entity;
1157+
1158+
// ...
1159+
use Symfony\Component\Validator\Mapping\ClassMetadata;
1160+
1161+
class User implements GroupSequenceProviderInterface
1162+
{
1163+
// ...
1164+
1165+
public static function loadValidatorMetadata(ClassMetadata $metadata)
1166+
{
1167+
$metadata->setGroupSequenceProvider(true);
1168+
// ...
1169+
}
1170+
}
1171+
11191172
.. _book-validation-raw-values:
11201173

11211174
Validating Values and Arrays

components/console/helpers/dialoghelper.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ This methods has 2 new arguments, the full signature is::
131131
string|array $question,
132132
callback $validator,
133133
integer $attempts = false,
134-
string $default = null
134+
string $default = null,
135+
array $autocomplete = null
135136
)
136137

137138
The ``$validator`` is a callback which handles the validation. It should
@@ -140,8 +141,8 @@ in the console, so it is a good practice to put some useful information in it. T
140141
function should also return the value of the user's input if the validation was successful.
141142

142143
You can set the max number of times to ask in the ``$attempts`` argument.
143-
If you reach this max number it will use the default value, which is given
144-
in the last argument. Using ``false`` means the amount of attempts is infinite.
144+
If you reach this max number it will use the default value.
145+
Using ``false`` means the amount of attempts is infinite.
145146
The user will be asked as long as they provide an invalid answer and will only
146147
be able to proceed if their input is valid.
147148

components/expression_language/syntax.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ to JavaScript::
4949
)
5050
);
5151

52-
This will print ``Honeycrisp``.
52+
This will print out ``Honeycrisp``.
5353

5454
Calling Methods
5555
~~~~~~~~~~~~~~~
@@ -79,7 +79,7 @@ JavaScript::
7979
)
8080
);
8181

82-
This will print ``Hi Hi Hi!``.
82+
This will print out ``Hi Hi Hi!``.
8383

8484
.. _component-expression-functions:
8585

@@ -97,7 +97,7 @@ constant::
9797
'constant("DB_USER")'
9898
);
9999

100-
This will print ``root``.
100+
This will print out ``root``.
101101

102102
.. tip::
103103

@@ -121,7 +121,7 @@ array keys, similar to JavaScript::
121121
)
122122
);
123123

124-
This will print ``42``.
124+
This will print out ``42``.
125125

126126
Supported Operators
127127
-------------------

contributing/code/standards.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ Structure
101101

102102
* Declare class properties before methods;
103103

104-
* Declare public methods first, then protected ones and finally private ones;
104+
* Declare public methods first, then protected ones and finally private ones.
105+
The exceptions to this rule are the class constructor and the ``setUp`` and
106+
``tearDown`` methods of PHPUnit tests, which should always be the first methods
107+
to increase readability;
105108

106109
* Use parentheses when instantiating classes regardless of the number of
107110
arguments the constructor has;

0 commit comments

Comments
 (0)