Skip to content

Commit

Permalink
Merge branch '2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed May 17, 2015
2 parents de9b3d5 + 1fa0659 commit 25c9705
Show file tree
Hide file tree
Showing 44 changed files with 497 additions and 414 deletions.
2 changes: 1 addition & 1 deletion components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ and :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`::
$nameConverter = new OrgPrefixNameConverter();
$normalizer = new PropertyNormalizer(null, $nameConverter);

$serializer = new Serializer(array(new JsonEncoder()), array($normalizer));
$serializer = new Serializer(array($normalizer), array(new JsonEncoder()));

$obj = new Company();
$obj->name = 'Acme Inc.';
Expand Down
5 changes: 1 addition & 4 deletions contributing/code/standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ Service Naming Conventions

* Use lowercase letters for service and parameter names;

* A group name uses the underscore notation;

* Each service has a corresponding parameter containing the class name,
following the ``SERVICE NAME.class`` convention.
* A group name uses the underscore notation.

Documentation
-------------
Expand Down
2 changes: 1 addition & 1 deletion cookbook/logging/monolog_email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ How to Configure Monolog to Email Errors
Monolog_ can be configured to send an email when an error occurs with an
application. The configuration for this requires a few nested handlers
in order to avoid receiving too many emails. This configuration looks
complicated at first but each handler is fairly straight forward when
complicated at first but each handler is fairly straightforward when
it is broken down.

.. configuration-block::
Expand Down
2 changes: 1 addition & 1 deletion cookbook/security/form_login_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Finally, create the template:
{# ... you will probably extends your base template, like base.html.twig #}

{% if error %}
<div>{{ error.messageKey|trans(error.messageData) }}</div>
<div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}

<form action="{{ path('login_check') }}" method="post">
Expand Down
16 changes: 12 additions & 4 deletions cookbook/security/voters_data_permission.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ from the authorization checker is called.
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class PostController extends Controller
{
Expand All @@ -213,9 +212,14 @@ from the authorization checker is called.
$post = ...;
// keep in mind, this will call all registered security voters
if (false === $this->get('security.authorization_checker')->isGranted('view', $post)) {
throw new AccessDeniedException('Unauthorised access!');
}
$this->denyAccessUnlessGranted('view', $post, 'Unauthorized access!');
// the equivalent code without using the denyAccessUnlessGranted() shortcut
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
//
// if (false === $this->get('security.authorization_checker')->isGranted('view', $post)) {
// throw new AccessDeniedException('Unauthorized access!');
// }
return new Response('<h1>'.$post->getName().'</h1>');
}
Expand All @@ -225,4 +229,8 @@ from the authorization checker is called.
The ``security.authorization_checker`` service was introduced in Symfony 2.6. Prior
to Symfony 2.6, you had to use the ``isGranted()`` method of the ``security.context`` service.

.. versionadded:: 2.6
The ``denyAccessUnlessGranted()`` method was introduced in Symfony 2.6 as a shortcut.
It uses ``security.authorization_checker`` and throws an ``AccessDeniedException`` if needed.

It's that easy!
12 changes: 6 additions & 6 deletions quick_tour/the_big_picture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ because that will be explained in the next section)::
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
* @Route("/app/example", name="homepage")
*/
public function indexAction()
{
Expand Down Expand Up @@ -198,7 +198,7 @@ at the three lines of code above the ``indexAction`` method::
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
* @Route("/app/example", name="homepage")
*/
public function indexAction()
{
Expand All @@ -219,10 +219,10 @@ the application homepage. The second value of ``@Route()`` (e.g.
``name="homepage"``) is optional and sets the name of this route. For now
this name is not needed, but later it'll be useful for linking pages.

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

.. tip::

Expand Down
22 changes: 11 additions & 11 deletions reference/constraints/All.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ All
When applied to an array (or Traversable object), this constraint allows
you to apply a collection of constraints to each element of the array.

+----------------+------------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+------------------------------------------------------------------------+
| Options | - `constraints`_ |
| | - `payload`_ |
+----------------+------------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` |
+----------------+------------------------------------------------------------------------+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` |
+----------------+------------------------------------------------------------------------+
+----------------+-------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+-------------------------------------------------------------------+
| Options | - `constraints`_ |
| | - `payload`_ |
+----------------+-------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\All` |
+----------------+-------------------------------------------------------------------+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\AllValidator` |
+----------------+-------------------------------------------------------------------+

Basic Usage
-----------

Suppose that you have an array of strings, and you want to validate each
Suppose that you have an array of strings and you want to validate each
entry in that array:

.. configuration-block::
Expand Down
26 changes: 13 additions & 13 deletions reference/constraints/Blank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ Blank

Validates that a value is blank, defined as equal to a blank string or equal
to ``null``. To force that a value strictly be equal to ``null``, see the
:doc:`/reference/constraints/Null` constraint. To force that a value is *not*
blank, see :doc:`/reference/constraints/NotBlank`.

+----------------+-----------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+-----------------------------------------------------------------------+
| Options | - `message`_ |
| | - `payload`_ |
+----------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` |
+----------------+-----------------------------------------------------------------------+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` |
+----------------+-----------------------------------------------------------------------+
:doc:`/reference/constraints/Null` constraint. To force that a value is
*not* blank, see :doc:`/reference/constraints/NotBlank`.

+----------------+---------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+---------------------------------------------------------------------+
| Options | - `message`_ |
| | - `payload`_ |
+----------------+---------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Blank` |
+----------------+---------------------------------------------------------------------+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\BlankValidator` |
+----------------+---------------------------------------------------------------------+

Basic Usage
-----------
Expand Down
26 changes: 13 additions & 13 deletions reference/constraints/Callback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ Callback
========

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

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

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

// ...
use Symfony\Component\Validator\Context\ExecutionContextInterface;
Expand Down Expand Up @@ -160,10 +160,10 @@ have access to the object instance, they receive the object as the first argumen
External Callbacks and Closures
-------------------------------

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

namespace Vendor\Package;

Expand Down Expand Up @@ -243,8 +243,8 @@ You can then use the following configuration to invoke this validator:
.. note::

The Callback constraint does *not* support global callback functions nor
is it possible to specify a global function or a :term:`service` method
The Callback constraint does *not* support global callback functions
nor is it possible to specify a global function or a :term:`service` method
as callback. To validate using a service, you should
:doc:`create a custom validation constraint </cookbook/validation/custom_constraint>`
and add that new constraint to your class.
Expand Down
20 changes: 12 additions & 8 deletions reference/constraints/CardScheme.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CardScheme
==========

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

+----------------+--------------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
Expand Down Expand Up @@ -35,7 +35,10 @@ on an object that will contain a credit card number.
class Transaction
{
/**
* @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.")
* @Assert\CardScheme(
* schemes={"VISA"},
* message="Your credit card number is invalid."
* )
*/
protected $cardNumber;
}
Expand Down Expand Up @@ -101,9 +104,9 @@ schemes

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

This option is required and represents the name of the number scheme used to
validate the credit card number, it can either be a string or an array. Valid
values are:
This option is required and represents the name of the number scheme used
to validate the credit card number, it can either be a string or an array.
Valid values are:

* ``AMEX``
* ``CHINA_UNIONPAY``
Expand All @@ -116,7 +119,8 @@ values are:
* ``MASTERCARD``
* ``VISA``

For more information about the used schemes, see `Wikipedia: Issuer identification number (IIN)`_.
For more information about the used schemes, see
`Wikipedia: Issuer identification number (IIN)`_.

message
~~~~~~~
Expand Down
55 changes: 28 additions & 27 deletions reference/constraints/Choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ This constraint is used to ensure that the given value is one of a given
set of *valid* choices. It can also be used to validate that each item in
an array of items is one of those valid choices.

+----------------+-----------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+-----------------------------------------------------------------------+
| Options | - `choices`_ |
| | - `callback`_ |
| | - `multiple`_ |
| | - `min`_ |
| | - `max`_ |
| | - `message`_ |
| | - `multipleMessage`_ |
| | - `minMessage`_ |
| | - `maxMessage`_ |
| | - `strict`_ |
| | - `payload`_ |
+----------------+-----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` |
+----------------+-----------------------------------------------------------------------+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` |
+----------------+-----------------------------------------------------------------------+
+----------------+----------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+----------------------------------------------------------------------+
| Options | - `choices`_ |
| | - `callback`_ |
| | - `multiple`_ |
| | - `min`_ |
| | - `max`_ |
| | - `message`_ |
| | - `multipleMessage`_ |
| | - `minMessage`_ |
| | - `maxMessage`_ |
| | - `strict`_ |
| | - `payload`_ |
+----------------+----------------------------------------------------------------------+
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` |
+----------------+----------------------------------------------------------------------+
| Validator | :class:`Symfony\\Component\\Validator\\Constraints\\ChoiceValidator` |
+----------------+----------------------------------------------------------------------+

Basic Usage
-----------
Expand Down Expand Up @@ -276,8 +276,8 @@ callback
**type**: ``string|array|Closure``

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

multiple
~~~~~~~~
Expand Down Expand Up @@ -314,16 +314,17 @@ message

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

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

multipleMessage
~~~~~~~~~~~~~~~

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

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

minMessage
Expand All @@ -348,7 +349,7 @@ strict
**type**: ``Boolean`` **default**: ``false``

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

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

0 comments on commit 25c9705

Please sign in to comment.