Skip to content

Commit 043fea4

Browse files
committed
Merge branch '2.3' into 2.7
Conflicts: reference/constraints/Callback.rst reference/constraints/Image.rst
2 parents ae3d583 + fdc7f75 commit 043fea4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+483
-468
lines changed

best_practices/forms.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ makes them easier to re-use later.
8585

8686
Add buttons in the templates, not in the form classes or the controllers.
8787

88-
Since Symfony 2.5, you can add buttons as fields on your form. This is a nice
88+
Since Symfony 2.3, you can add buttons as fields on your form. This is a nice
8989
way to simplify the template that renders your form. But if you add the buttons
9090
directly in your form class, this would effectively limit the scope of that form:
9191

book/testing.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ expression or a CSS selector, then use the client to click on it. For example::
196196
$link = $crawler
197197
->filter('a:contains("Greet")') // find all links with the text "Greet"
198198
->eq(1) // select the second link in the list
199-
->link() // and click it
199+
->link()
200200
;
201-
201+
202+
// and click it
202203
$crawler = $client->click($link);
203204

204205
Submitting a form is very similar: select a form button, optionally override

reference/constraints/All.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ entry in that array:
2525

2626
.. code-block:: php-annotations
2727
28-
// src/Acme/UserBundle/Entity/User.php
29-
namespace Acme\UserBundle\Entity;
28+
// src/AppBundle/Entity/User.php
29+
namespace AppBundle\Entity;
3030
3131
use Symfony\Component\Validator\Constraints as Assert;
3232
@@ -43,8 +43,8 @@ entry in that array:
4343
4444
.. code-block:: yaml
4545
46-
# src/Acme/UserBundle/Resources/config/validation.yml
47-
Acme\UserBundle\Entity\User:
46+
# src/AppBundle/Resources/config/validation.yml
47+
AppBundle\Entity\User:
4848
properties:
4949
favoriteColors:
5050
- All:
@@ -54,13 +54,13 @@ entry in that array:
5454
5555
.. code-block:: xml
5656
57-
<!-- src/Acme/UserBundle/Resources/config/validation.xml -->
57+
<!-- src/AppBundle/Resources/config/validation.xml -->
5858
<?xml version="1.0" encoding="UTF-8" ?>
5959
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
6060
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6161
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6262
63-
<class name="Acme\UserBundle\Entity\User">
63+
<class name="AppBundle\Entity\User">
6464
<property name="favoriteColors">
6565
<constraint name="All">
6666
<option name="constraints">
@@ -76,8 +76,8 @@ entry in that array:
7676
7777
.. code-block:: php
7878
79-
// src/Acme/UserBundle/Entity/User.php
80-
namespace Acme\UserBundle\Entity;
79+
// src/AppBundle/Entity/User.php
80+
namespace AppBundle\Entity;
8181
8282
use Symfony\Component\Validator\Mapping\ClassMetadata;
8383
use Symfony\Component\Validator\Constraints as Assert;

reference/constraints/Blank.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ of an ``Author`` class were blank, you could do the following:
2727

2828
.. code-block:: php-annotations
2929
30-
// src/Acme/BlogBundle/Entity/Author.php
31-
namespace Acme\BlogBundle\Entity;
30+
// src/AppBundle/Entity/Author.php
31+
namespace AppBundle\Entity;
3232
3333
use Symfony\Component\Validator\Constraints as Assert;
3434
@@ -42,21 +42,21 @@ of an ``Author`` class were blank, you could do the following:
4242
4343
.. code-block:: yaml
4444
45-
# src/Acme/BlogBundle/Resources/config/validation.yml
46-
Acme\BlogBundle\Entity\Author:
45+
# src/AppBundle/Resources/config/validation.yml
46+
AppBundle\Entity\Author:
4747
properties:
4848
firstName:
4949
- Blank: ~
5050
5151
.. code-block:: xml
5252
53-
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
53+
<!-- src/AppBundle/Resources/config/validation.xml -->
5454
<?xml version="1.0" encoding="UTF-8" ?>
5555
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
5656
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5757
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
5858
59-
<class name="Acme\BlogBundle\Entity\Author">
59+
<class name="AppBundle\Entity\Author">
6060
<property name="firstName">
6161
<constraint name="Blank" />
6262
</property>
@@ -65,8 +65,8 @@ of an ``Author`` class were blank, you could do the following:
6565
6666
.. code-block:: php
6767
68-
// src/Acme/BlogBundle/Entity/Author.php
69-
namespace Acme\BlogBundle\Entity;
68+
// src/AppBundle/Entity/Author.php
69+
namespace AppBundle\Entity;
7070
7171
use Symfony\Component\Validator\Mapping\ClassMetadata;
7272
use Symfony\Component\Validator\Constraints as Assert;

reference/constraints/Callback.rst

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Configuration
3535

3636
.. code-block:: php-annotations
3737
38-
// src/Acme/BlogBundle/Entity/Author.php
39-
namespace Acme\BlogBundle\Entity;
38+
// src/AppBundle/Entity/Author.php
39+
namespace AppBundle\Entity;
4040
4141
use Symfony\Component\Validator\Constraints as Assert;
4242
use Symfony\Component\Validator\Context\ExecutionContextInterface;
@@ -56,28 +56,28 @@ Configuration
5656
5757
.. code-block:: yaml
5858
59-
# src/Acme/BlogBundle/Resources/config/validation.yml
60-
Acme\BlogBundle\Entity\Author:
59+
# src/AppBundle/Resources/config/validation.yml
60+
AppBundle\Entity\Author:
6161
constraints:
6262
- Callback: [validate]
6363
6464
.. code-block:: xml
6565
66-
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
66+
<!-- src/AppBundle/Resources/config/validation.xml -->
6767
<?xml version="1.0" encoding="UTF-8" ?>
6868
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
6969
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7070
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
7171
72-
<class name="Acme\BlogBundle\Entity\Author">
72+
<class name="AppBundle\Entity\Author">
7373
<constraint name="Callback">validate</constraint>
7474
</class>
7575
</constraint-mapping>
7676
7777
.. code-block:: php
7878
79-
// src/Acme/BlogBundle/Entity/Author.php
80-
namespace Acme\BlogBundle\Entity;
79+
// src/AppBundle/Entity/Author.php
80+
namespace AppBundle\Entity;
8181
8282
use Symfony\Component\Validator\Mapping\ClassMetadata;
8383
use Symfony\Component\Validator\Constraints as Assert;
@@ -185,57 +185,69 @@ You can then use the following configuration to invoke this validator:
185185

186186
.. code-block:: php-annotations
187187
188-
// src/Acme/BlogBundle/Entity/Author.php
188+
// src/AppBundle/Entity/Author.php
189189
namespace Acme\BlogBundle\Entity;
190190
191191
use Symfony\Component\Validator\Constraints as Assert;
192192
193193
/**
194-
* @Assert\Callback({"Vendor\Package\Validator", "validate"})
194+
* @Assert\Callback({"AppBundle\MyStaticValidatorClass", "isAuthorValid"})
195195
*/
196196
class Author
197197
{
198198
}
199199
200200
.. code-block:: yaml
201201
202-
# src/Acme/BlogBundle/Resources/config/validation.yml
203-
Acme\BlogBundle\Entity\Author:
204-
constraints:
205-
- Callback: [Vendor\Package\Validator, validate]
202+
# src/AppBundle/Resources/config/validation.yml
203+
AppBundle\Entity\Author:
204+
constraints:
205+
- Callback:
206+
methods:
207+
- [AppBundle\MyStaticValidatorClass, isAuthorValid]
206208

207209
.. code-block:: xml
208210
209-
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
210-
<?xml version="1.0" encoding="UTF-8" ?>
211-
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
212-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
213-
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
214-
215-
<class name="Acme\BlogBundle\Entity\Author">
216-
<constraint name="Callback">
217-
<value>Vendor\Package\Validator</value>
218-
<value>validate</value>
219-
</constraint>
220-
</class>
221-
</constraint-mapping>
211+
<!-- src/AppBundle/Resources/config/validation.xml -->
212+
<?xml version="1.0" encoding="UTF-8" ?>
213+
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
214+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
215+
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
216+
217+
<class name="AppBundle\Entity\Author">
218+
<constraint name="Callback">
219+
<option name="methods">
220+
<value>
221+
<value>AppBundle\MyStaticValidatorClass</value>
222+
<value>isAuthorValid</value>
223+
</value>
224+
</option>
225+
</constraint>
226+
</class>
227+
</constraint-mapping>
222228

223229
.. code-block:: php
224230
225-
// src/Acme/BlogBundle/Entity/Author.php
226-
namespace Acme\BlogBundle\Entity;
231+
// src/AppBundle/Entity/Author.php
232+
namespace AppBundle\Entity;
227233

228234
use Symfony\Component\Validator\Mapping\ClassMetadata;
229235
use Symfony\Component\Validator\Constraints as Assert;
230236

231237
class Author
232238
{
239+
public $name;
240+
233241
public static function loadValidatorMetadata(ClassMetadata $metadata)
234242
{
235-
$metadata->addConstraint(new Assert\Callback(array(
236-
'Vendor\Package\Validator',
237-
'validate',
238-
)));
243+
$metadata->addConstraint(new Callback(array(
244+
'methods' => array(
245+
array(
246+
'AppBundle\MyStaticValidatorClass',
247+
'isAuthorValid',
248+
),
249+
),
250+
)));
239251
}
240252
}
241253

@@ -250,8 +262,11 @@ You can then use the following configuration to invoke this validator:
250262
When configuring the constraint via PHP, you can also pass a closure to the
251263
constructor of the Callback constraint::
252264

253-
// src/Acme/BlogBundle/Entity/Author.php
254-
namespace Acme\BlogBundle\Entity;
265+
// src/AppBundle/Entity/Author.php
266+
namespace AppBundle\Entity;
267+
268+
use Symfony\Component\Validator\ExecutionContextInterface;
269+
use AppBundle\Entity\Author;
255270

256271
use Symfony\Component\Validator\Mapping\ClassMetadata;
257272
use Symfony\Component\Validator\Constraints as Assert;

reference/constraints/CardScheme.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ on an object that will contain a credit card number.
2727

2828
.. code-block:: php-annotations
2929
30-
// src/Acme/SubscriptionBundle/Entity/Transaction.php
31-
namespace Acme\SubscriptionBundle\Entity\Transaction;
30+
// src/AppBundle/Entity/Transaction.php
31+
namespace AppBundle\Entity\Transaction;
3232
3333
use Symfony\Component\Validator\Constraints as Assert;
3434
@@ -45,8 +45,8 @@ on an object that will contain a credit card number.
4545
4646
.. code-block:: yaml
4747
48-
# src/Acme/SubscriptionBundle/Resources/config/validation.yml
49-
Acme\SubscriptionBundle\Entity\Transaction:
48+
# src/AppBundle/Resources/config/validation.yml
49+
AppBundle\Entity\Transaction:
5050
properties:
5151
cardNumber:
5252
- CardScheme:
@@ -55,13 +55,13 @@ on an object that will contain a credit card number.
5555
5656
.. code-block:: xml
5757
58-
<!-- src/Acme/SubscriptionBundle/Resources/config/validation.xml -->
58+
<!-- src/AppBundle/Resources/config/validation.xml -->
5959
<?xml version="1.0" encoding="UTF-8" ?>
6060
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
6161
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6262
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6363
64-
<class name="Acme\SubscriptionBundle\Entity\Transaction">
64+
<class name="AppBundle\Entity\Transaction">
6565
<property name="cardNumber">
6666
<constraint name="CardScheme">
6767
<option name="schemes">
@@ -75,8 +75,8 @@ on an object that will contain a credit card number.
7575
7676
.. code-block:: php
7777
78-
// src/Acme/SubscriptionBundle/Entity/Transaction.php
79-
namespace Acme\SubscriptionBundle\Entity\Transaction;
78+
// src/AppBundle/Entity/Transaction.php
79+
namespace AppBundle\Entity\Transaction;
8080
8181
use Symfony\Component\Validator\Mapping\ClassMetadata;
8282
use Symfony\Component\Validator\Constraints as Assert;

0 commit comments

Comments
 (0)