Skip to content

Commit fdc7f75

Browse files
committed
minor #5645 Updated Constraint reference with best practices (WouterJ)
This PR was merged into the 2.3 branch. Discussion ---------- Updated Constraint reference with best practices | Q | A | --- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | - A quick search & replace to use AppBundle in the constraint docs. After a quick scan, I think we don't have to update anything else in the constraint reference in order to comply with the best practices. Commits ------- fe7aa8b Updated Constraint reference with best practices
2 parents 038a7d2 + fe7aa8b commit fdc7f75

Some content is hidden

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

43 files changed

+450
-450
lines changed

reference/constraints/All.rst

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

2525
.. code-block:: php-annotations
2626
27-
// src/Acme/UserBundle/Entity/User.php
28-
namespace Acme\UserBundle\Entity;
27+
// src/AppBundle/Entity/User.php
28+
namespace AppBundle\Entity;
2929
3030
use Symfony\Component\Validator\Constraints as Assert;
3131
@@ -42,8 +42,8 @@ entry in that array:
4242
4343
.. code-block:: yaml
4444
45-
# src/Acme/UserBundle/Resources/config/validation.yml
46-
Acme\UserBundle\Entity\User:
45+
# src/AppBundle/Resources/config/validation.yml
46+
AppBundle\Entity\User:
4747
properties:
4848
favoriteColors:
4949
- All:
@@ -53,13 +53,13 @@ entry in that array:
5353
5454
.. code-block:: xml
5555
56-
<!-- src/Acme/UserBundle/Resources/config/validation.xml -->
56+
<!-- src/AppBundle/Resources/config/validation.xml -->
5757
<?xml version="1.0" encoding="UTF-8" ?>
5858
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
5959
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6060
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6161
62-
<class name="Acme\UserBundle\Entity\User">
62+
<class name="AppBundle\Entity\User">
6363
<property name="favoriteColors">
6464
<constraint name="All">
6565
<option name="constraints">
@@ -75,8 +75,8 @@ entry in that array:
7575
7676
.. code-block:: php
7777
78-
// src/Acme/UserBundle/Entity/User.php
79-
namespace Acme\UserBundle\Entity;
78+
// src/AppBundle/Entity/User.php
79+
namespace AppBundle\Entity;
8080
8181
use Symfony\Component\Validator\Mapping\ClassMetadata;
8282
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
@@ -26,8 +26,8 @@ of an ``Author`` class were blank, you could do the following:
2626

2727
.. code-block:: php-annotations
2828
29-
// src/Acme/BlogBundle/Entity/Author.php
30-
namespace Acme\BlogBundle\Entity;
29+
// src/AppBundle/Entity/Author.php
30+
namespace AppBundle\Entity;
3131
3232
use Symfony\Component\Validator\Constraints as Assert;
3333
@@ -41,21 +41,21 @@ of an ``Author`` class were blank, you could do the following:
4141
4242
.. code-block:: yaml
4343
44-
# src/Acme/BlogBundle/Resources/config/validation.yml
45-
Acme\BlogBundle\Entity\Author:
44+
# src/AppBundle/Resources/config/validation.yml
45+
AppBundle\Entity\Author:
4646
properties:
4747
firstName:
4848
- Blank: ~
4949
5050
.. code-block:: xml
5151
52-
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
52+
<!-- src/AppBundle/Resources/config/validation.xml -->
5353
<?xml version="1.0" encoding="UTF-8" ?>
5454
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
5555
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5656
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
5757
58-
<class name="Acme\BlogBundle\Entity\Author">
58+
<class name="AppBundle\Entity\Author">
5959
<property name="firstName">
6060
<constraint name="Blank" />
6161
</property>
@@ -64,8 +64,8 @@ of an ``Author`` class were blank, you could do the following:
6464
6565
.. code-block:: php
6666
67-
// src/Acme/BlogBundle/Entity/Author.php
68-
namespace Acme\BlogBundle\Entity;
67+
// src/AppBundle/Entity/Author.php
68+
namespace AppBundle\Entity;
6969
7070
use Symfony\Component\Validator\Mapping\ClassMetadata;
7171
use Symfony\Component\Validator\Constraints as Assert;

reference/constraints/Callback.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ Setup
3434

3535
.. code-block:: php-annotations
3636
37-
// src/Acme/BlogBundle/Entity/Author.php
38-
namespace Acme\BlogBundle\Entity;
37+
// src/AppBundle/Entity/Author.php
38+
namespace AppBundle\Entity;
3939
4040
use Symfony\Component\Validator\Constraints as Assert;
4141
@@ -48,21 +48,21 @@ Setup
4848
4949
.. code-block:: yaml
5050
51-
# src/Acme/BlogBundle/Resources/config/validation.yml
52-
Acme\BlogBundle\Entity\Author:
51+
# src/AppBundle/Resources/config/validation.yml
52+
AppBundle\Entity\Author:
5353
constraints:
5454
- Callback:
5555
methods: [isAuthorValid]
5656
5757
.. code-block:: xml
5858
59-
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
59+
<!-- src/AppBundle/Resources/config/validation.xml -->
6060
<?xml version="1.0" encoding="UTF-8" ?>
6161
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
6262
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6363
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6464
65-
<class name="Acme\BlogBundle\Entity\Author">
65+
<class name="AppBundle\Entity\Author">
6666
<constraint name="Callback">
6767
<option name="methods">
6868
<value>isAuthorValid</value>
@@ -73,8 +73,8 @@ Setup
7373
7474
.. code-block:: php
7575
76-
// src/Acme/BlogBundle/Entity/Author.php
77-
namespace Acme\BlogBundle\Entity;
76+
// src/AppBundle/Entity/Author.php
77+
namespace AppBundle\Entity;
7878
7979
use Symfony\Component\Validator\Mapping\ClassMetadata;
8080
use Symfony\Component\Validator\Constraints as Assert;
@@ -147,12 +147,12 @@ process. Each method can be one of the following formats:
147147

148148
.. code-block:: php-annotations
149149
150-
// src/Acme/BlogBundle/Entity/Author.php
150+
// src/AppBundle/Entity/Author.php
151151
use Symfony\Component\Validator\Constraints as Assert;
152152
153153
/**
154154
* @Assert\Callback(methods={
155-
* { "Acme\BlogBundle\MyStaticValidatorClass", "isAuthorValid" }
155+
* { "AppBundle\MyStaticValidatorClass", "isAuthorValid" }
156156
* })
157157
*/
158158
class Author
@@ -161,26 +161,26 @@ process. Each method can be one of the following formats:
161161
162162
.. code-block:: yaml
163163
164-
# src/Acme/BlogBundle/Resources/config/validation.yml
165-
Acme\BlogBundle\Entity\Author:
164+
# src/AppBundle/Resources/config/validation.yml
165+
AppBundle\Entity\Author:
166166
constraints:
167167
- Callback:
168168
methods:
169-
- [Acme\BlogBundle\MyStaticValidatorClass, isAuthorValid]
169+
- [AppBundle\MyStaticValidatorClass, isAuthorValid]
170170
171171
.. code-block:: xml
172172
173-
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
173+
<!-- src/AppBundle/Resources/config/validation.xml -->
174174
<?xml version="1.0" encoding="UTF-8" ?>
175175
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
176176
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
177177
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
178178
179-
<class name="Acme\BlogBundle\Entity\Author">
179+
<class name="AppBundle\Entity\Author">
180180
<constraint name="Callback">
181181
<option name="methods">
182182
<value>
183-
<value>Acme\BlogBundle\MyStaticValidatorClass</value>
183+
<value>AppBundle\MyStaticValidatorClass</value>
184184
<value>isAuthorValid</value>
185185
</value>
186186
</option>
@@ -190,7 +190,7 @@ process. Each method can be one of the following formats:
190190
191191
.. code-block:: php
192192
193-
// src/Acme/BlogBundle/Entity/Author.php
193+
// src/AppBundle/Entity/Author.php
194194
195195
use Symfony\Component\Validator\Mapping\ClassMetadata;
196196
use Symfony\Component\Validator\Constraints\Callback;
@@ -204,7 +204,7 @@ process. Each method can be one of the following formats:
204204
$metadata->addConstraint(new Callback(array(
205205
'methods' => array(
206206
array(
207-
'Acme\BlogBundle\MyStaticValidatorClass',
207+
'AppBundle\MyStaticValidatorClass',
208208
'isAuthorValid',
209209
),
210210
),
@@ -213,14 +213,14 @@ process. Each method can be one of the following formats:
213213
}
214214
215215
In this case, the static method ``isAuthorValid`` will be called on
216-
the ``Acme\BlogBundle\MyStaticValidatorClass`` class. It's passed both
216+
the ``AppBundle\MyStaticValidatorClass`` class. It's passed both
217217
the original object being validated (e.g. ``Author``) as well as the
218218
``ExecutionContextInterface``::
219219

220-
namespace Acme\BlogBundle;
220+
namespace AppBundle;
221221

222222
use Symfony\Component\Validator\ExecutionContextInterface;
223-
use Acme\BlogBundle\Entity\Author;
223+
use AppBundle\Entity\Author;
224224

225225
class MyStaticValidatorClass
226226
{

reference/constraints/CardScheme.rst

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

3030
.. code-block:: php-annotations
3131
32-
// src/Acme/SubscriptionBundle/Entity/Transaction.php
33-
namespace Acme\SubscriptionBundle\Entity\Transaction;
32+
// src/AppBundle/Entity/Transaction.php
33+
namespace AppBundle\Entity\Transaction;
3434
3535
use Symfony\Component\Validator\Constraints as Assert;
3636
@@ -47,8 +47,8 @@ on an object that will contain a credit card number.
4747
4848
.. code-block:: yaml
4949
50-
# src/Acme/SubscriptionBundle/Resources/config/validation.yml
51-
Acme\SubscriptionBundle\Entity\Transaction:
50+
# src/AppBundle/Resources/config/validation.yml
51+
AppBundle\Entity\Transaction:
5252
properties:
5353
cardNumber:
5454
- CardScheme:
@@ -57,13 +57,13 @@ on an object that will contain a credit card number.
5757
5858
.. code-block:: xml
5959
60-
<!-- src/Acme/SubscriptionBundle/Resources/config/validation.xml -->
60+
<!-- src/AppBundle/Resources/config/validation.xml -->
6161
<?xml version="1.0" encoding="UTF-8" ?>
6262
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
6363
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6464
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6565
66-
<class name="Acme\SubscriptionBundle\Entity\Transaction">
66+
<class name="AppBundle\Entity\Transaction">
6767
<property name="cardNumber">
6868
<constraint name="CardScheme">
6969
<option name="schemes">
@@ -77,8 +77,8 @@ on an object that will contain a credit card number.
7777
7878
.. code-block:: php
7979
80-
// src/Acme/SubscriptionBundle/Entity/Transaction.php
81-
namespace Acme\SubscriptionBundle\Entity\Transaction;
80+
// src/AppBundle/Entity/Transaction.php
81+
namespace AppBundle\Entity\Transaction;
8282
8383
use Symfony\Component\Validator\Mapping\ClassMetadata;
8484
use Symfony\Component\Validator\Constraints as Assert;

0 commit comments

Comments
 (0)