Skip to content

Commit 1fa0659

Browse files
committed
Merge branch '2.6' into 2.7
Conflicts: reference/constraints/Callback.rst reference/dic_tags.rst
2 parents d9a0d04 + ce9ba27 commit 1fa0659

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

+496
-413
lines changed

contributing/code/standards.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,7 @@ Service Naming Conventions
165165

166166
* Use lowercase letters for service and parameter names;
167167

168-
* A group name uses the underscore notation;
169-
170-
* Each service has a corresponding parameter containing the class name,
171-
following the ``SERVICE NAME.class`` convention.
168+
* A group name uses the underscore notation.
172169

173170
Documentation
174171
-------------

cookbook/logging/monolog_email.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ How to Configure Monolog to Email Errors
77
Monolog_ can be configured to send an email when an error occurs with an
88
application. The configuration for this requires a few nested handlers
99
in order to avoid receiving too many emails. This configuration looks
10-
complicated at first but each handler is fairly straight forward when
10+
complicated at first but each handler is fairly straightforward when
1111
it is broken down.
1212

1313
.. configuration-block::

cookbook/security/form_login_setup.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Finally, create the template:
215215
{# ... you will probably extends your base template, like base.html.twig #}
216216

217217
{% if error %}
218-
<div>{{ error.messageKey|trans(error.messageData) }}</div>
218+
<div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
219219
{% endif %}
220220

221221
<form action="{{ path('login_check') }}" method="post">

cookbook/security/voters_data_permission.rst

+12-4
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ from the authorization checker is called.
203203
204204
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
205205
use Symfony\Component\HttpFoundation\Response;
206-
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
207206
208207
class PostController extends Controller
209208
{
@@ -213,9 +212,14 @@ from the authorization checker is called.
213212
$post = ...;
214213
215214
// keep in mind, this will call all registered security voters
216-
if (false === $this->get('security.authorization_checker')->isGranted('view', $post)) {
217-
throw new AccessDeniedException('Unauthorised access!');
218-
}
215+
$this->denyAccessUnlessGranted('view', $post, 'Unauthorized access!');
216+
217+
// the equivalent code without using the denyAccessUnlessGranted() shortcut
218+
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
219+
//
220+
// if (false === $this->get('security.authorization_checker')->isGranted('view', $post)) {
221+
// throw new AccessDeniedException('Unauthorized access!');
222+
// }
219223
220224
return new Response('<h1>'.$post->getName().'</h1>');
221225
}
@@ -225,4 +229,8 @@ from the authorization checker is called.
225229
The ``security.authorization_checker`` service was introduced in Symfony 2.6. Prior
226230
to Symfony 2.6, you had to use the ``isGranted()`` method of the ``security.context`` service.
227231

232+
.. versionadded:: 2.6
233+
The ``denyAccessUnlessGranted()`` method was introduced in Symfony 2.6 as a shortcut.
234+
It uses ``security.authorization_checker`` and throws an ``AccessDeniedException`` if needed.
235+
228236
It's that easy!

quick_tour/the_big_picture.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ because that will be explained in the next section)::
156156
class DefaultController extends Controller
157157
{
158158
/**
159-
* @Route("/", name="homepage")
159+
* @Route("/app/example", name="homepage")
160160
*/
161161
public function indexAction()
162162
{
@@ -198,7 +198,7 @@ at the three lines of code above the ``indexAction`` method::
198198
class DefaultController extends Controller
199199
{
200200
/**
201-
* @Route("/", name="homepage")
201+
* @Route("/app/example", name="homepage")
202202
*/
203203
public function indexAction()
204204
{
@@ -219,10 +219,10 @@ the application homepage. The second value of ``@Route()`` (e.g.
219219
``name="homepage"``) is optional and sets the name of this route. For now
220220
this name is not needed, but later it'll be useful for linking pages.
221221

222-
Considering all this, the ``@Route("/", name="homepage")`` annotation creates
223-
a new route called ``homepage`` which makes Symfony execute the ``index``
224-
action of the ``Default`` controller when the user browses the ``/`` path
225-
of the application.
222+
Considering all this, the ``@Route("/app/example", name="homepage")`` annotation
223+
creates a new route called ``homepage`` which makes Symfony execute the
224+
``index`` action of the ``Default`` controller when the user browses the
225+
``/app/example`` path of the application.
226226

227227
.. tip::
228228

reference/constraints/All.rst

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ All
44
When applied to an array (or Traversable object), this constraint allows
55
you to apply a collection of constraints to each element of the array.
66

7-
+----------------+------------------------------------------------------------------------+
8-
| Applies to | :ref:`property or method <validation-property-target>` |
9-
+----------------+------------------------------------------------------------------------+
10-
| Options | - `constraints`_ |
11-
| | - `payload`_ |
12-
+----------------+------------------------------------------------------------------------+
13-
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` |
14-
+----------------+------------------------------------------------------------------------+
15-
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` |
16-
+----------------+------------------------------------------------------------------------+
7+
+----------------+-------------------------------------------------------------------+
8+
| Applies to | :ref:`property or method <validation-property-target>` |
9+
+----------------+-------------------------------------------------------------------+
10+
| Options | - `constraints`_ |
11+
| | - `payload`_ |
12+
+----------------+-------------------------------------------------------------------+
13+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` |
14+
+----------------+-------------------------------------------------------------------+
15+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` |
16+
+----------------+-------------------------------------------------------------------+
1717

1818
Basic Usage
1919
-----------
2020

21-
Suppose that you have an array of strings, and you want to validate each
21+
Suppose that you have an array of strings and you want to validate each
2222
entry in that array:
2323

2424
.. configuration-block::

reference/constraints/Blank.rst

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ Blank
33

44
Validates that a value is blank, defined as equal to a blank string or equal
55
to ``null``. To force that a value strictly be equal to ``null``, see the
6-
:doc:`/reference/constraints/Null` constraint. To force that a value is *not*
7-
blank, see :doc:`/reference/constraints/NotBlank`.
8-
9-
+----------------+-----------------------------------------------------------------------+
10-
| Applies to | :ref:`property or method <validation-property-target>` |
11-
+----------------+-----------------------------------------------------------------------+
12-
| Options | - `message`_ |
13-
| | - `payload`_ |
14-
+----------------+-----------------------------------------------------------------------+
15-
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` |
16-
+----------------+-----------------------------------------------------------------------+
17-
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` |
18-
+----------------+-----------------------------------------------------------------------+
6+
:doc:`/reference/constraints/Null` constraint. To force that a value is
7+
*not* blank, see :doc:`/reference/constraints/NotBlank`.
8+
9+
+----------------+---------------------------------------------------------------------+
10+
| Applies to | :ref:`property or method <validation-property-target>` |
11+
+----------------+---------------------------------------------------------------------+
12+
| Options | - `message`_ |
13+
| | - `payload`_ |
14+
+----------------+---------------------------------------------------------------------+
15+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` |
16+
+----------------+---------------------------------------------------------------------+
17+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` |
18+
+----------------+---------------------------------------------------------------------+
1919

2020
Basic Usage
2121
-----------

reference/constraints/Callback.rst

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ Callback
22
========
33

44
The purpose of the Callback constraint is to create completely custom
5-
validation rules and to assign any validation errors to specific fields on
6-
your object. If you're using validation with forms, this means that you can
7-
make these custom errors display next to a specific field, instead of simply
8-
at the top of your form.
5+
validation rules and to assign any validation errors to specific fields
6+
on your object. If you're using validation with forms, this means that you
7+
can make these custom errors display next to a specific field, instead of
8+
simply at the top of your form.
99

1010
This process works by specifying one or more *callback* methods, each of
1111
which will be called during the validation process. Each of those methods
@@ -93,9 +93,9 @@ Configuration
9393
The Callback Method
9494
-------------------
9595

96-
The callback method is passed a special ``ExecutionContextInterface`` object. You
97-
can set "violations" directly on this object and determine to which field
98-
those errors should be attributed::
96+
The callback method is passed a special ``ExecutionContextInterface`` object.
97+
You can set "violations" directly on this object and determine to which
98+
field those errors should be attributed::
9999

100100
// ...
101101
use Symfony\Component\Validator\Context\ExecutionContextInterface;
@@ -160,10 +160,10 @@ have access to the object instance, they receive the object as the first argumen
160160
External Callbacks and Closures
161161
-------------------------------
162162

163-
If you want to execute a static callback method that is not located in the class
164-
of the validated object, you can configure the constraint to invoke an array
165-
callable as supported by PHP's :phpfunction:`call_user_func` function. Suppose
166-
your validation function is ``Vendor\Package\Validator::validate()``::
163+
If you want to execute a static callback method that is not located in the
164+
class of the validated object, you can configure the constraint to invoke
165+
an array callable as supported by PHP's :phpfunction:`call_user_func` function.
166+
Suppose your validation function is ``Vendor\Package\Validator::validate()``::
167167

168168
namespace Vendor\Package;
169169

@@ -243,8 +243,8 @@ You can then use the following configuration to invoke this validator:
243243
244244
.. note::
245245

246-
The Callback constraint does *not* support global callback functions nor
247-
is it possible to specify a global function or a :term:`service` method
246+
The Callback constraint does *not* support global callback functions
247+
nor is it possible to specify a global function or a :term:`service` method
248248
as callback. To validate using a service, you should
249249
:doc:`create a custom validation constraint </cookbook/validation/custom_constraint>`
250250
and add that new constraint to your class.

reference/constraints/CardScheme.rst

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
CardScheme
22
==========
33

4-
This constraint ensures that a credit card number is valid for a given credit card
5-
company. It can be used to validate the number before trying to initiate a payment
6-
through a payment gateway.
4+
This constraint ensures that a credit card number is valid for a given credit
5+
card company. It can be used to validate the number before trying to initiate
6+
a payment through a payment gateway.
77

88
+----------------+--------------------------------------------------------------------------+
99
| Applies to | :ref:`property or method <validation-property-target>` |
@@ -35,7 +35,10 @@ on an object that will contain a credit card number.
3535
class Transaction
3636
{
3737
/**
38-
* @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.")
38+
* @Assert\CardScheme(
39+
* schemes={"VISA"},
40+
* message="Your credit card number is invalid."
41+
* )
3942
*/
4043
protected $cardNumber;
4144
}
@@ -101,9 +104,9 @@ schemes
101104

102105
**type**: ``mixed`` [:ref:`default option <validation-default-option>`]
103106

104-
This option is required and represents the name of the number scheme used to
105-
validate the credit card number, it can either be a string or an array. Valid
106-
values are:
107+
This option is required and represents the name of the number scheme used
108+
to validate the credit card number, it can either be a string or an array.
109+
Valid values are:
107110

108111
* ``AMEX``
109112
* ``CHINA_UNIONPAY``
@@ -116,7 +119,8 @@ values are:
116119
* ``MASTERCARD``
117120
* ``VISA``
118121

119-
For more information about the used schemes, see `Wikipedia: Issuer identification number (IIN)`_.
122+
For more information about the used schemes, see
123+
`Wikipedia: Issuer identification number (IIN)`_.
120124

121125
message
122126
~~~~~~~

reference/constraints/Choice.rst

+28-27
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ This constraint is used to ensure that the given value is one of a given
55
set of *valid* choices. It can also be used to validate that each item in
66
an array of items is one of those valid choices.
77

8-
+----------------+-----------------------------------------------------------------------+
9-
| Applies to | :ref:`property or method <validation-property-target>` |
10-
+----------------+-----------------------------------------------------------------------+
11-
| Options | - `choices`_ |
12-
| | - `callback`_ |
13-
| | - `multiple`_ |
14-
| | - `min`_ |
15-
| | - `max`_ |
16-
| | - `message`_ |
17-
| | - `multipleMessage`_ |
18-
| | - `minMessage`_ |
19-
| | - `maxMessage`_ |
20-
| | - `strict`_ |
21-
| | - `payload`_ |
22-
+----------------+-----------------------------------------------------------------------+
23-
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` |
24-
+----------------+-----------------------------------------------------------------------+
25-
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` |
26-
+----------------+-----------------------------------------------------------------------+
8+
+----------------+----------------------------------------------------------------------+
9+
| Applies to | :ref:`property or method <validation-property-target>` |
10+
+----------------+----------------------------------------------------------------------+
11+
| Options | - `choices`_ |
12+
| | - `callback`_ |
13+
| | - `multiple`_ |
14+
| | - `min`_ |
15+
| | - `max`_ |
16+
| | - `message`_ |
17+
| | - `multipleMessage`_ |
18+
| | - `minMessage`_ |
19+
| | - `maxMessage`_ |
20+
| | - `strict`_ |
21+
| | - `payload`_ |
22+
+----------------+----------------------------------------------------------------------+
23+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` |
24+
+----------------+----------------------------------------------------------------------+
25+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` |
26+
+----------------+----------------------------------------------------------------------+
2727

2828
Basic Usage
2929
-----------
@@ -276,8 +276,8 @@ callback
276276
**type**: ``string|array|Closure``
277277

278278
This is a callback method that can be used instead of the `choices`_ option
279-
to return the choices array. See `Supplying the Choices with a Callback Function`_
280-
for details on its usage.
279+
to return the choices array. See
280+
`Supplying the Choices with a Callback Function`_ for details on its usage.
281281

282282
multiple
283283
~~~~~~~~
@@ -314,16 +314,17 @@ message
314314

315315
**type**: ``string`` **default**: ``The value you selected is not a valid choice.``
316316

317-
This is the message that you will receive if the ``multiple`` option is set
318-
to ``false``, and the underlying value is not in the valid array of choices.
317+
This is the message that you will receive if the ``multiple`` option is
318+
set to ``false`` and the underlying value is not in the valid array of
319+
choices.
319320

320321
multipleMessage
321322
~~~~~~~~~~~~~~~
322323

323324
**type**: ``string`` **default**: ``One or more of the given values is invalid.``
324325

325-
This is the message that you will receive if the ``multiple`` option is set
326-
to ``true``, and one of the values on the underlying array being checked
326+
This is the message that you will receive if the ``multiple`` option is
327+
set to ``true`` and one of the values on the underlying array being checked
327328
is not in the array of valid choices.
328329

329330
minMessage
@@ -348,7 +349,7 @@ strict
348349
**type**: ``Boolean`` **default**: ``false``
349350

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

354355
.. include:: /reference/constraints/_payload-option.rst.inc

0 commit comments

Comments
 (0)