Skip to content

Commit f1caeb3

Browse files
committed
Merge branch '2.1'
2 parents 23c8e48 + 4be1ae1 commit f1caeb3

20 files changed

+217
-40
lines changed

components/filesystem.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ Installation
1616
You can install the component in many different ways:
1717

1818
* Use the official Git repository (https://github.com/symfony/Filesystem);
19-
* Install it via PEAR ( `pear.symfony.com/Filesystem`);
20-
* Install it via Composer (`symfony/filesystem` on Packagist).
19+
* Install it via Composer (``symfony/filesystem`` on `Packagist`_).
2120

2221
Usage
2322
-----
@@ -240,3 +239,5 @@ thrown.
240239
returned a boolean and did not throw exceptions. As of 2.1, a
241240
:class:`Symfony\\Component\\Filesystem\\Exception\\IOException` is
242241
thrown if a directory creation fails.
242+
243+
.. _`Packagist`: https://packagist.org/packages/symfony/filesystem

components/routing/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ If you're using the ``YamlFileLoader``, then route definitions look like this:
245245
# routes.yml
246246
route1:
247247
pattern: /foo
248-
defaults: { controller: 'MyController::fooAction' }
248+
defaults: { _controller: 'MyController::fooAction' }
249249
250250
route2:
251251
pattern: /foo/bar
252-
defaults: { controller: 'MyController::foobarAction' }
252+
defaults: { _controller: 'MyController::foobarAction' }
253253
254254
To load this file, you can use the following code. This assumes that your
255255
``routes.yml`` file is in the same directory as the below code::

reference/constraints/All.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ entry in that array:
5151
protected $favoriteColors = array();
5252
}
5353
54+
.. code-block:: xml
55+
56+
<!-- src/Acme/UserBundle/Resources/config/validation.xml -->
57+
<class name="Acme\UserBundle\Entity\User">
58+
<property name="favoriteColors">
59+
<constraint name="All">
60+
<option name="constraints">
61+
<constraint name="NotBlank" />
62+
<constraint name="Length">
63+
<option name="min">5</option>
64+
</constraint>
65+
</option>
66+
</constraint>
67+
</property>
68+
</class>
69+
5470
Now, each entry in the ``favoriteColors`` array will be validated to not
5571
be blank and to be at least 5 characters long.
5672

reference/constraints/Choice.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ If your valid choice list is simple, you can pass them in directly via the
4949
.. code-block:: xml
5050
5151
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
52-
<class name="Acme\BlogBundle\EntityAuthor">
52+
<class name="Acme\BlogBundle\Entity\Author">
5353
<property name="gender">
5454
<constraint name="Choice">
5555
<option name="choices">
@@ -280,4 +280,4 @@ strict
280280

281281
If true, the validator will also check the type of the input value. Specifically,
282282
this value is passed to as the third argument to the PHP :phpfunction:`in_array` method
283-
when checking to see if a value is in the valid choices array.
283+
when checking to see if a value is in the valid choices array.

reference/constraints/Count.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ you might add the following:
3838
- Count:
3939
min: 1
4040
max: 5
41-
minMessage: You must specify at least one email
42-
maxMessage: You cannot specify more than 5 emails
41+
minMessage: "You must specify at least one email"
42+
maxMessage: "You cannot specify more than {{ limit }} emails"
4343
4444
.. code-block:: php-annotations
4545
@@ -53,12 +53,27 @@ you might add the following:
5353
* min = "1",
5454
* max = "5",
5555
* minMessage = "You must specify at least one email",
56-
* maxMessage = "You cannot specify more than 5 emails"
56+
* maxMessage = "You cannot specify more than {{ limit }} emails"
5757
* )
5858
*/
5959
protected $emails = array();
6060
}
6161
62+
.. code-block:: xml
63+
64+
<!-- src/Acme/EventBundle/Resources/config/validation.xml -->
65+
<class name="Acme\EventBundle\Entity\Participant">
66+
<property name="emails">
67+
<constraint name="Count">
68+
<option name="min">1</option>
69+
<option name="max">5</option>
70+
<option name="minMessage">You must specify at least one email</option>
71+
<option name="maxMessage">You cannot specify more than {{ limit }} emails</option>
72+
</constraint>
73+
</property>
74+
</class>
75+
76+
6277
Options
6378
-------
6479

reference/constraints/Country.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ Basic Usage
4141
protected $country;
4242
}
4343
44+
.. code-block:: xml
45+
46+
<!-- src/Acme/UserBundle/Resources/config/validation.xml -->
47+
<class name="Acme\UserBundle\Entity\User">
48+
<property name="country">
49+
<constraint name="Country" />
50+
</property>
51+
</class>
52+
4453
Options
4554
-------
4655

reference/constraints/Date.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ Basic Usage
4141
protected $birthday;
4242
}
4343
44+
.. code-block:: xml
45+
46+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
47+
<class name="Acme\BlogBundle\Entity\Author">
48+
<property name="birthday">
49+
<constraint name="Date" />
50+
</property>
51+
</class>
52+
4453
Options
4554
-------
4655

reference/constraints/DateTime.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ Basic Usage
4343
protected $createdAt;
4444
}
4545
46+
.. code-block:: xml
47+
48+
<!-- src/Acme/UserBundle/Resources/config/validation.xml -->
49+
<class name="Acme\BlogBundle\Entity\Author">
50+
<property name="createdAt">
51+
<constraint name="DateTime" />
52+
</property>
53+
</class>
54+
4655
Options
4756
-------
4857

reference/constraints/False.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ method returns **false**:
4848
- "False":
4949
message: You've entered an invalid state.
5050
51+
.. code-block:: xml
52+
53+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
54+
<class name="Acme\BlogBundle\Entity\Author">
55+
<getter property="stateInvalid">
56+
<constraint name="False">
57+
<option name="message">You've entered an invalid state.</option>
58+
</constraint>
59+
</getter>
60+
</class>
61+
5162
.. code-block:: php-annotations
5263
5364
// src/Acme/BlogBundle/Entity/Author.php

reference/constraints/Ip.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ Basic Usage
4444
protected $ipAddress;
4545
}
4646
47+
.. code-block:: xml
48+
49+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
50+
<class name="Acme\BlogBundle\Entity\Author">
51+
<property name="ipAddress">
52+
<constraint name="Ip" />
53+
</property>
54+
</class>
55+
4756
Options
4857
-------
4958

reference/constraints/Language.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ Basic Usage
4141
protected $preferredLanguage;
4242
}
4343
44+
.. code-block:: xml
45+
46+
<!-- src/Acme/UserBundle/Resources/config/validation.xml -->
47+
<class name="Acme\UserBundle\Entity\User">
48+
<property name="preferredLanguage">
49+
<constraint name="Language" />
50+
</property>
51+
</class>
52+
4453
Options
4554
-------
4655

reference/constraints/Length.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ To verify that the ``firstName`` field length of a class is between "2" and
6161
6262
.. code-block:: xml
6363
64-
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
64+
<!-- src/Acme/EventBundle/Resources/config/validation.xml -->
6565
<class name="Acme\EventBundle\Entity\Participant">
6666
<property name="firstName">
6767
<constraint name="Length">

reference/constraints/Locale.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ Basic Usage
4545
protected $locale;
4646
}
4747
48+
.. code-block:: xml
49+
50+
<!-- src/Acme/UserBundle/Resources/config/validation.xml -->
51+
<class name="Acme\UserBundle\Entity\User">
52+
<property name="locale">
53+
<constraint name="Locale" />
54+
</property>
55+
</class>
56+
4857
Options
4958
-------
5059

reference/constraints/Max.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ add the following:
5050
protected $age;
5151
}
5252
53+
.. code-block:: xml
54+
55+
<!-- src/Acme/EventBundle/Resources/config/validation.yml -->
56+
<class name="Acme\EventBundle\Entity\Participant">
57+
<property name="age">
58+
<constraint name="Max">
59+
<option name="limit">50</option>
60+
<option name="message">You must be 50 or under to enter.</option>
61+
</constraint>
62+
</property>
63+
</class>
64+
5365
Options
5466
-------
5567

reference/constraints/Range.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ the following:
5858
protected $height;
5959
}
6060
61+
.. code-block:: xml
62+
63+
<!-- src/Acme/EventBundle/Resources/config/validation.xml -->
64+
<class name="Acme\EventBundle\Entity\Participant">
65+
<property name="height">
66+
<constraint name="Range">
67+
<option name="min">120</option>
68+
<option name="max">180</option>
69+
<option name="minMessage">You must be at least 120cm tall to enter</option>
70+
<option name="maxMessage">You cannot be taller than 180cm to enter</option>
71+
</constraint>
72+
</property>
73+
</class>
74+
6175
Options
6276
-------
6377

reference/constraints/Regex.rst

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ characters at the beginning of your string:
4848
protected $description;
4949
}
5050
51+
.. code-block:: xml
52+
53+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
54+
<class name="Acme\BlogBundle\Entity\Author">
55+
<property name="description">
56+
<constraint name="Regex">
57+
<option name="pattern">/^\w+/</option>
58+
</constraint>
59+
</property>
60+
</class>
61+
5162
Alternatively, you can set the `match`_ option to ``false`` in order to assert
5263
that a given string does *not* match. In the following example, you'll assert
5364
that the ``firstName`` field does not contain any numbers and give it a custom
@@ -85,6 +96,19 @@ message:
8596
protected $firstName;
8697
}
8798
99+
.. code-block:: xml
100+
101+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
102+
<class name="Acme\BlogBundle\Entity\Author">
103+
<property name="firstName">
104+
<constraint name="Regex">
105+
<option name="pattern">/\d/</option>
106+
<option name="match">false</option>
107+
<option name="message">Your name cannot contain a number</option>
108+
</constraint>
109+
</property>
110+
</class>
111+
88112
Options
89113
-------
90114

@@ -114,4 +138,4 @@ message
114138

115139
**type**: ``string`` **default**: ``This value is not valid``
116140

117-
This is the message that will be shown if this validator fails.
141+
This is the message that will be shown if this validator fails.

reference/constraints/Time.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ of the day when the event starts:
4646
protected $startsAt;
4747
}
4848
49+
.. code-block:: xml
50+
51+
<!-- src/Acme/EventBundle/Resources/config/validation.xml -->
52+
<class name="Acme\EventBundle\Entity\Event">
53+
<property name="startsAt">
54+
<constraint name="Time" />
55+
</property>
56+
</class>
57+
4958
Options
5059
-------
5160

0 commit comments

Comments
 (0)