From 396302b3185aa8afe506fecab8633ee377a778f6 Mon Sep 17 00:00:00 2001 From: Diego Gullo Date: Sat, 6 Jun 2015 12:59:48 +0100 Subject: [PATCH 01/49] Added description on how to enable the security:check command through composer --- book/security.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/book/security.rst b/book/security.rst index 2f3ed0f30a6..bf67ee07743 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1352,6 +1352,13 @@ FriendsOfPHP organization. any of your dependencies is affected by a known security vulnerability. Therefore, you can easily integrate it in your build process. + To enable the ``security:check`` command, you need to add the + `sensio distribution bundle`_ in your composer dependencies. + +.. code-block:: bash + + $ composer require 'sensio/distribution-bundle:~3' + Final Words ----------- @@ -1381,3 +1388,4 @@ Learn More from the Cookbook .. _`online tool`: https://www.dailycred.com/blog/12/bcrypt-calculator .. _`frameworkextrabundle documentation`: http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html .. _`security advisories database`: https://github.com/FriendsOfPHP/security-advisories +.. _`sensio distribution bundle`: https://packagist.org/packages/sensio/distribution-bundle From 5aa7044df77f645c4ec64d585299eb65bc1d7ed5 Mon Sep 17 00:00:00 2001 From: Diego Gullo Date: Sun, 7 Jun 2015 15:03:52 +0100 Subject: [PATCH 02/49] Improved security:check command description --- book/security.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/book/security.rst b/book/security.rst index bf67ee07743..d84fac51825 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1352,12 +1352,14 @@ FriendsOfPHP organization. any of your dependencies is affected by a known security vulnerability. Therefore, you can easily integrate it in your build process. +.. note:: + To enable the ``security:check`` command, you need to add the `sensio distribution bundle`_ in your composer dependencies. .. code-block:: bash - $ composer require 'sensio/distribution-bundle:~3' + $ composer require 'sensio/distribution-bundle' Final Words ----------- From aa0dff43591d6f3ede5557a7e0f67595df910fe5 Mon Sep 17 00:00:00 2001 From: Diego Gullo Date: Sun, 7 Jun 2015 18:33:54 +0100 Subject: [PATCH 03/49] Indented code block in security:check command description --- book/security.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/security.rst b/book/security.rst index d84fac51825..aa86bec3af9 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1357,9 +1357,9 @@ FriendsOfPHP organization. To enable the ``security:check`` command, you need to add the `sensio distribution bundle`_ in your composer dependencies. -.. code-block:: bash + .. code-block:: bash - $ composer require 'sensio/distribution-bundle' + $ composer require 'sensio/distribution-bundle' Final Words ----------- From 5c872f26bc89d722bea29fe7c6b52e8a526e27e6 Mon Sep 17 00:00:00 2001 From: Diego Gullo Date: Wed, 10 Jun 2015 19:31:40 +0100 Subject: [PATCH 04/49] Bundle name case change --- book/security.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/security.rst b/book/security.rst index aa86bec3af9..1ef235cc361 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1355,7 +1355,7 @@ FriendsOfPHP organization. .. note:: To enable the ``security:check`` command, you need to add the - `sensio distribution bundle`_ in your composer dependencies. + `SensioDistributionBundle`_ in your composer dependencies. .. code-block:: bash @@ -1390,4 +1390,4 @@ Learn More from the Cookbook .. _`online tool`: https://www.dailycred.com/blog/12/bcrypt-calculator .. _`frameworkextrabundle documentation`: http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html .. _`security advisories database`: https://github.com/FriendsOfPHP/security-advisories -.. _`sensio distribution bundle`: https://packagist.org/packages/sensio/distribution-bundle +.. _`SensioDistributionBundle`: https://packagist.org/packages/sensio/distribution-bundle From dae28115f5b9395e7a28c0ee125c4f755efeeb9a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 24 May 2015 12:32:57 -0700 Subject: [PATCH 05/49] Fix missing note about debug.dump_destination --- components/var_dumper/introduction.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/components/var_dumper/introduction.rst b/components/var_dumper/introduction.rst index 05eff3e8849..086695c471c 100644 --- a/components/var_dumper/introduction.rst +++ b/components/var_dumper/introduction.rst @@ -104,6 +104,11 @@ original value. You can configure the limits in terms of: * maximum number of items to dump, * maximum string length before truncation. +Since dumping into the toolbar is not always possible - e.g. when working on a +JSON API - you can have an alternate output destination for dumps. This is +configurable with the ``debug.dump_destination`` option, that you can typically +set to ``php://stderr``. + .. configuration-block:: .. code-block:: yaml @@ -111,6 +116,7 @@ original value. You can configure the limits in terms of: debug: max_items: 250 max_string_length: -1 + dump_destination: ~ .. code-block:: xml @@ -119,9 +125,17 @@ original value. You can configure the limits in terms of: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/debug http://symfony.com/schema/dic/debug/debug-1.0.xsd"> - + + .. code-block:: php + + $container->loadFromExtension('debug', array( + 'max_items' => 250, + 'max_string_length' => -1, + 'dump_destination' => null, + )); + Dump Examples and Output ------------------------ From 11383f8ad5be5abed7fe006110a57a8b518809ca Mon Sep 17 00:00:00 2001 From: Henry Snoek Date: Thu, 28 May 2015 12:41:39 +0200 Subject: [PATCH 06/49] 4668 document isCsrfTokenValid --- book/controller.rst | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/book/controller.rst b/book/controller.rst index 7ec7bd4ae3a..18555aeb521 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -440,7 +440,7 @@ If you want to redirect the user to another page, use the ``redirectToRoute()`` } .. versionadded:: 2.6 - The ``redirectToRoute()`` method was added in Symfony 2.6. Previously (and still now), you + The ``redirectToRoute()`` method was introduced in Symfony 2.6. Previously (and still now), you could use ``redirect()`` and ``generateUrl()`` together for this (see the example above). Or, if you want to redirect externally, just use ``redirect()`` and pass it the URL:: @@ -803,6 +803,28 @@ Just like when creating a controller for a route, the order of the arguments of order of the arguments, Symfony will still pass the correct value to each variable. +Validating a CSRF Token +----------------------- + +Sometimes you want to use CSRF protection in an action where you don't want to use the +Symfony Form component. + +If, for example, you're doing a DELETE action, you can use the +:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::isCsrfTokenValid` +method to check the CSRF token:: + + if ($this->isCsrfTokenValid('token_id', $submittedToken)) { + // ... do something, like deleting an object + } + +.. versionadded:: 2.6 + The ``isCsrfTokenValid()`` shortcut method was introduced in Symfony 2.6. + It is equivalent to executing the following code:: + + use Symfony\Component\Security\Csrf\CsrfToken; + + $this->get('security.csrf.token_manager')->isTokenValid(new CsrfToken('token_id', 'TOKEN')); + Final Thoughts -------------- From f67c353b576d5b1e65d72b36db939b85f1833913 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Wed, 29 Jul 2015 13:53:52 +0200 Subject: [PATCH 07/49] [#5572] Fix syntax --- book/controller.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/book/controller.rst b/book/controller.rst index 18555aeb521..8b1f2dc7a47 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -806,11 +806,9 @@ variable. Validating a CSRF Token ----------------------- -Sometimes you want to use CSRF protection in an action where you don't want to use the -Symfony Form component. - -If, for example, you're doing a DELETE action, you can use the -:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::isCsrfTokenValid` +Sometimes, you want to use CSRF protection in an action where you don't want to +use the Symfony Form component. If, for example, you're doing a DELETE action, +you can use the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::isCsrfTokenValid` method to check the CSRF token:: if ($this->isCsrfTokenValid('token_id', $submittedToken)) { @@ -821,9 +819,10 @@ method to check the CSRF token:: The ``isCsrfTokenValid()`` shortcut method was introduced in Symfony 2.6. It is equivalent to executing the following code:: - use Symfony\Component\Security\Csrf\CsrfToken; + use Symfony\Component\Security\Csrf\CsrfToken; - $this->get('security.csrf.token_manager')->isTokenValid(new CsrfToken('token_id', 'TOKEN')); + $this->get('security.csrf.token_manager') + ->isTokenValid(new CsrfToken('token_id', 'TOKEN')); Final Thoughts -------------- From 4db7055dae6e4406405bfa32ad7458f712bfe35c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 27 Sep 2015 12:36:27 +0200 Subject: [PATCH 08/49] update versionadded directive to match the content --- cookbook/security/voters.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cookbook/security/voters.rst b/cookbook/security/voters.rst index ec5404ef2a9..d995e2af41b 100644 --- a/cookbook/security/voters.rst +++ b/cookbook/security/voters.rst @@ -207,9 +207,10 @@ How to Use the Voter in a Controller ------------------------------------ The registered voter will then always be asked as soon as the method ``isGranted()`` -from the authorization checker is called. - -.. code-block:: php +from the authorization checker is called. When extending the base ``Controller`` +class, you can simply call the +:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::denyAccessUnlessGranted()` +method:: // src/AppBundle/Controller/PostController.php namespace AppBundle\Controller; @@ -232,9 +233,9 @@ from the authorization checker is called. } .. versionadded:: 2.6 - 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. + The ``denyAccessUnlessGranted()`` method was introduced in Symfony 2.6. + Prior to Symfony 2.6, you had to call the ``isGranted()`` method of the + ``security.context`` service and throw the exception yourself. It's that easy! From 9794d5849ea2ead2c8595e59bd0a6771eb5b153b Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 28 Sep 2015 19:49:31 +0200 Subject: [PATCH 09/49] do not distinguish regular classes and API classes --- contributing/code/bc.rst | 401 +++++++++++++++------------------------ 1 file changed, 153 insertions(+), 248 deletions(-) diff --git a/contributing/code/bc.rst b/contributing/code/bc.rst index 95613bd1763..905accabb6e 100644 --- a/contributing/code/bc.rst +++ b/contributing/code/bc.rst @@ -51,53 +51,28 @@ sticks to these rules. The exception to this rule are interfaces tagged with ``@internal``. Such interfaces should not be used or implemented. -If you want to implement an interface, you should first make sure that the -interface is an API interface. You can recognize API interfaces by the ``@api`` -tag in their source code:: - - /** - * HttpKernelInterface handles a Request to convert it to a Response. - * - * @author Fabien Potencier - * - * @api - */ - interface HttpKernelInterface - { - // ... - } - -If you implement an API interface, we promise that we won't ever break your -code. Regular interfaces, by contrast, may be extended between minor releases, -for example by adding a new method. Be prepared to upgrade your code manually -if you implement a regular interface. - -.. note:: - - Even if we do changes that require manual upgrades, we limit ourselves to - changes that can be upgraded easily. We will always document the precise - upgrade instructions in the UPGRADE file in Symfony's root directory. +If you implement an interface, we promise that we won't ever break your code. The following table explains in detail which use cases are covered by our backwards compatibility promise: -+-----------------------------------------------+---------------+---------------+ -| Use Case | Regular | API | -+===============================================+===============+===============+ -| **If you...** | **Then we guarantee BC...** | -+-----------------------------------------------+---------------+---------------+ -| Type hint against the interface | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ -| Call a method | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ -| **If you implement the interface and...** | **Then we guarantee BC...** | -+-----------------------------------------------+---------------+---------------+ -| Implement a method | No [1]_ | Yes | -+-----------------------------------------------+---------------+---------------+ -| Add an argument to an implemented method | No [1]_ | Yes | -+-----------------------------------------------+---------------+---------------+ -| Add a default value to an argument | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ ++-----------------------------------------------+-----------------------------+ +| Use Case | Backwards Compatibility | ++===============================================+=============================+ +| **If you...** | **Then we guarantee BC...** | ++-----------------------------------------------+-----------------------------+ +| Type hint against the interface | Yes | ++-----------------------------------------------+-----------------------------+ +| Call a method | Yes | ++-----------------------------------------------+-----------------------------+ +| **If you implement the interface and...** | **Then we guarantee BC...** | ++-----------------------------------------------+-----------------------------+ +| Implement a method | Yes | ++-----------------------------------------------+-----------------------------+ +| Add an argument to an implemented method | Yes | ++-----------------------------------------------+-----------------------------+ +| Add a default value to an argument | Yes | ++-----------------------------------------------+-----------------------------+ .. include:: _api_tagging.rst.inc @@ -114,82 +89,50 @@ public methods and properties. exception to this rule. They are meant for internal use only and should not be accessed by your own code. -Just like with interfaces, we also distinguish between regular and API classes. -Like API interfaces, API classes are marked with an ``@api`` tag:: - - /** - * Request represents an HTTP request. - * - * @author Fabien Potencier - * - * @api - */ - class Request - { - // ... - } - -The difference between regular and API classes is that we guarantee full -backwards compatibility if you extend an API class and override its methods. We -can't give the same promise for regular classes, because there we may, for -example, add an optional argument to a method. Consequently, the signature of -your overridden method wouldn't match anymore and generate a fatal error. - -.. note:: - - As with interfaces, we limit ourselves to changes that can be upgraded - easily. We will document the precise upgrade instructions in the UPGRADE - file in Symfony's root directory. - -In some cases, only specific properties and methods are tagged with the ``@api`` -tag, even though their class is not. In these cases, we guarantee full backwards -compatibility for the tagged properties and methods (as indicated in the column -"API" below), but not for the rest of the class. - To be on the safe side, check the following table to know which use cases are covered by our backwards compatibility promise: -+-----------------------------------------------+---------------+---------------+ -| Use Case | Regular | API | -+===============================================+===============+===============+ -| **If you...** | **Then we guarantee BC...** | -+-----------------------------------------------+---------------+---------------+ -| Type hint against the class | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ -| Create a new instance | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ -| Extend the class | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ -| Access a public property | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ -| Call a public method | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ -| **If you extend the class and...** | **Then we guarantee BC...** | -+-----------------------------------------------+---------------+---------------+ -| Access a protected property | No [1]_ | Yes | -+-----------------------------------------------+---------------+---------------+ -| Call a protected method | No [1]_ | Yes | -+-----------------------------------------------+---------------+---------------+ -| Override a public property | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ -| Override a protected property | No [1]_ | Yes | -+-----------------------------------------------+---------------+---------------+ -| Override a public method | No [1]_ | Yes | -+-----------------------------------------------+---------------+---------------+ -| Override a protected method | No [1]_ | Yes | -+-----------------------------------------------+---------------+---------------+ -| Add a new property | No | No | -+-----------------------------------------------+---------------+---------------+ -| Add a new method | No | No | -+-----------------------------------------------+---------------+---------------+ -| Add an argument to an overridden method | No [1]_ | Yes | -+-----------------------------------------------+---------------+---------------+ -| Add a default value to an argument | Yes | Yes | -+-----------------------------------------------+---------------+---------------+ -| Call a private method (via Reflection) | No | No | -+-----------------------------------------------+---------------+---------------+ -| Access a private property (via Reflection) | No | No | -+-----------------------------------------------+---------------+---------------+ ++-----------------------------------------------+-----------------------------+ +| Use Case | Backwards Compatibility | ++===============================================+=============================+ +| **If you...** | **Then we guarantee BC...** | ++-----------------------------------------------+-----------------------------+ +| Type hint against the class | Yes | ++-----------------------------------------------+-----------------------------+ +| Create a new instance | Yes | ++-----------------------------------------------+-----------------------------+ +| Extend the class | Yes | ++-----------------------------------------------+-----------------------------+ +| Access a public property | Yes | ++-----------------------------------------------+-----------------------------+ +| Call a public method | Yes | ++-----------------------------------------------+-----------------------------+ +| **If you extend the class and...** | **Then we guarantee BC...** | ++-----------------------------------------------+-----------------------------+ +| Access a protected property | Yes | ++-----------------------------------------------+-----------------------------+ +| Call a protected method | Yes | ++-----------------------------------------------+-----------------------------+ +| Override a public property | Yes | ++-----------------------------------------------+-----------------------------+ +| Override a protected property | Yes | ++-----------------------------------------------+-----------------------------+ +| Override a public method | Yes | ++-----------------------------------------------+-----------------------------+ +| Override a protected method | Yes | ++-----------------------------------------------+-----------------------------+ +| Add a new property | No | ++-----------------------------------------------+-----------------------------+ +| Add a new method | No | ++-----------------------------------------------+-----------------------------+ +| Add an argument to an overridden method | Yes | ++-----------------------------------------------+-----------------------------+ +| Add a default value to an argument | Yes | ++-----------------------------------------------+-----------------------------+ +| Call a private method (via Reflection) | No | ++-----------------------------------------------+-----------------------------+ +| Access a private property (via Reflection) | No | ++-----------------------------------------------+-----------------------------+ .. include:: _api_tagging.rst.inc @@ -205,28 +148,28 @@ Changing Interfaces This table tells you which changes you are allowed to do when working on Symfony's interfaces: -============================================== ============== ============== -Type of Change Regular API -============================================== ============== ============== -Remove entirely No No -Change name or namespace No No -Add parent interface Yes [2]_ Yes [3]_ -Remove parent interface No No +============================================== ============== +Type of Change Change Allowed +============================================== ============== +Remove entirely No +Change name or namespace No +Add parent interface Yes [2]_ +Remove parent interface No **Methods** -Add method Yes [2]_ No -Remove method No No -Change name No No -Move to parent interface Yes Yes -Add argument without a default value No No -Add argument with a default value Yes [2]_ No -Remove argument Yes [4]_ Yes [4]_ -Add default value to an argument Yes [2]_ No -Remove default value of an argument No No -Add type hint to an argument No No -Remove type hint of an argument Yes [2]_ No -Change argument type Yes [2]_ [5]_ No -Change return type Yes [2]_ [6]_ No -============================================== ============== ============== +Add method No +Remove method No +Change name No +Move to parent interface Yes +Add argument without a default value No +Add argument with a default value No +Remove argument Yes [3]_ +Add default value to an argument No +Remove default value of an argument No +Add type hint to an argument No +Remove type hint of an argument No +Change argument type No +Change return type No +============================================== ============== Changing Classes ~~~~~~~~~~~~~~~~ @@ -234,134 +177,96 @@ Changing Classes This table tells you which changes you are allowed to do when working on Symfony's classes: -================================================== ============== ============== -Type of Change Regular API -================================================== ============== ============== -Remove entirely No No -Make final No No -Make abstract No No -Change name or namespace No No -Change parent class Yes [7]_ Yes [7]_ -Add interface Yes Yes -Remove interface No No +================================================== ============== +Type of Change Change Allowed +================================================== ============== +Remove entirely No +Make final No +Make abstract No +Change name or namespace No +Change parent class Yes [4]_ +Add interface Yes +Remove interface No **Public Properties** -Add public property Yes Yes -Remove public property No No -Reduce visibility No No -Move to parent class Yes Yes +Add public property Yes +Remove public property No +Reduce visibility No +Move to parent class Yes **Protected Properties** -Add protected property Yes Yes -Remove protected property Yes [2]_ No -Reduce visibility Yes [2]_ No -Move to parent class Yes Yes +Add protected property Yes +Remove protected property No +Reduce visibility No +Move to parent class Yes **Private Properties** -Add private property Yes Yes -Remove private property Yes Yes +Add private property Yes +Remove private property Yes **Constructors** -Add constructor without mandatory arguments Yes [2]_ Yes [2]_ -Remove constructor Yes [2]_ No -Reduce visibility of a public constructor No No -Reduce visibility of a protected constructor Yes [2]_ No -Move to parent class Yes Yes +Add constructor without mandatory arguments Yes [1]_ +Remove constructor No +Reduce visibility of a public constructor No +Reduce visibility of a protected constructor No +Move to parent class Yes **Public Methods** -Add public method Yes Yes -Remove public method No No -Change name No No -Reduce visibility No No -Move to parent class Yes Yes -Add argument without a default value No No -Add argument with a default value Yes [2]_ No -Remove argument Yes [4]_ Yes [4]_ -Add default value to an argument Yes [2]_ No -Remove default value of an argument No No -Add type hint to an argument Yes [8]_ No -Remove type hint of an argument Yes [2]_ No -Change argument type Yes [2]_ [5]_ No -Change return type Yes [2]_ [6]_ No +Add public method Yes +Remove public method No +Change name No +Reduce visibility No +Move to parent class Yes +Add argument without a default value No +Add argument with a default value No +Remove argument Yes [3]_ +Add default value to an argument No +Remove default value of an argument No +Add type hint to an argument No +Remove type hint of an argument No +Change argument type No +Change return type No **Protected Methods** -Add protected method Yes Yes -Remove protected method Yes [2]_ No -Change name No No -Reduce visibility Yes [2]_ No -Move to parent class Yes Yes -Add argument without a default value Yes [2]_ No -Add argument with a default value Yes [2]_ No -Remove argument Yes [4]_ Yes [4]_ -Add default value to an argument Yes [2]_ No -Remove default value of an argument Yes [2]_ No -Add type hint to an argument Yes [2]_ No -Remove type hint of an argument Yes [2]_ No -Change argument type Yes [2]_ [5]_ No -Change return type Yes [2]_ [6]_ No +Add protected method Yes +Remove protected method No +Change name No +Reduce visibility No +Move to parent class Yes +Add argument without a default value No +Add argument with a default value No +Remove argument Yes [3]_ +Add default value to an argument No +Remove default value of an argument No +Add type hint to an argument No +Remove type hint of an argument No +Change argument type No +Change return type No **Private Methods** -Add private method Yes Yes -Remove private method Yes Yes -Change name Yes Yes -Reduce visibility Yes Yes -Add argument without a default value Yes Yes -Add argument with a default value Yes Yes -Remove argument Yes Yes -Add default value to an argument Yes Yes -Remove default value of an argument Yes Yes -Add type hint to an argument Yes Yes -Remove type hint of an argument Yes Yes -Change argument type Yes Yes -Change return type Yes Yes +Add private method Yes +Remove private method Yes +Change name Yes +Reduce visibility Yes +Add argument without a default value Yes +Add argument with a default value Yes +Remove argument Yes +Add default value to an argument Yes +Remove default value of an argument Yes +Add type hint to an argument Yes +Remove type hint of an argument Yes +Change argument type Yes +Change return type Yes **Static Methods** -Turn non static into static No No -Turn static into non static No No -================================================== ============== ============== - -.. [1] Your code may be broken by changes in the Symfony code. Such changes will - however be documented in the UPGRADE file. +Turn non static into static No +Turn static into non static No +================================================== ============== -.. [2] Should be avoided. When done, this change must be documented in the +.. [1] Should be avoided. When done, this change must be documented in the UPGRADE file. -.. [3] The added parent interface must not introduce any new methods that don't +.. [2] The added parent interface must not introduce any new methods that don't exist in the interface already. -.. [4] Only the last argument(s) of a method may be removed, as PHP does not +.. [3] Only the last argument(s) of a method may be removed, as PHP does not care about additional arguments that you pass to a method. -.. [5] The argument type may only be changed to a compatible or less specific - type. The following type changes are allowed: - - =================== ================================================================== - Original Type New Type - =================== ================================================================== - boolean any `scalar type`_ with equivalent `boolean values`_ - string any `scalar type`_ or object with equivalent `string values`_ - integer any `scalar type`_ with equivalent `integer values`_ - float any `scalar type`_ with equivalent `float values`_ - class ```` any superclass or interface of ```` - interface ```` any superinterface of ```` - =================== ================================================================== - -.. [6] The return type may only be changed to a compatible or more specific - type. The following type changes are allowed: - - =================== ================================================================== - Original Type New Type - =================== ================================================================== - boolean any `scalar type`_ with equivalent `boolean values`_ - string any `scalar type`_ or object with equivalent `string values`_ - integer any `scalar type`_ with equivalent `integer values`_ - float any `scalar type`_ with equivalent `float values`_ - array instance of ``ArrayAccess``, ``Traversable`` and ``Countable`` - ``ArrayAccess`` array - ``Traversable`` array - ``Countable`` array - class ```` any subclass of ```` - interface ```` any subinterface or implementing class of ```` - =================== ================================================================== - -.. [7] When changing the parent class, the original parent class must remain an +.. [4] When changing the parent class, the original parent class must remain an ancestor of the class. -.. [8] A type hint may only be added if passing a value with a different type - previously generated a fatal error. - .. _Semantic Versioning: http://semver.org/ .. _scalar type: http://php.net/manual/en/function.is-scalar.php .. _boolean values: http://php.net/manual/en/function.boolval.php From 74771b7f4ec65545fb892cc0ef963153f84365ee Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 7 Oct 2015 21:25:37 +0200 Subject: [PATCH 10/49] clarify description of the getPosition() method --- cookbook/security/custom_authentication_provider.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook/security/custom_authentication_provider.rst b/cookbook/security/custom_authentication_provider.rst index 4f437808e4e..eaf9f7ffee6 100644 --- a/cookbook/security/custom_authentication_provider.rst +++ b/cookbook/security/custom_authentication_provider.rst @@ -354,8 +354,8 @@ requires the following methods: to the DI container for the appropriate security context. ``getPosition`` - Method which must be of type ``pre_auth``, ``form``, ``http``, - and ``remember_me`` and defines the position at which the provider is called. + Method which defines the position at which the provider is called. The + returned value must be one of ``pre_auth``, ``form``, ``http`` or ``remember_me``. ``getKey`` Method which defines the configuration key used to reference From 5e2c1af13e25bcd4cdcd6e2be76c690f18315feb Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sun, 11 Oct 2015 00:03:36 +0200 Subject: [PATCH 11/49] Show a more real example in data collectors doc --- cookbook/profiler/data_collector.rst | 149 +++++++++++++++------------ 1 file changed, 82 insertions(+), 67 deletions(-) diff --git a/cookbook/profiler/data_collector.rst b/cookbook/profiler/data_collector.rst index 47229033063..b011bb878d4 100644 --- a/cookbook/profiler/data_collector.rst +++ b/cookbook/profiler/data_collector.rst @@ -4,7 +4,7 @@ How to Create a custom Data Collector ===================================== -:doc:`The Symfony Profiler ` delegates data collection +The :doc:`Symfony Profiler ` delegates data collection to some special classes called data collectors. Symfony comes bundled with a few of them, but you can easily create your own. @@ -16,70 +16,71 @@ Creating a custom data collector is as simple as implementing the interface DataCollectorInterface { - /** - * Collects data for the given Request and Response. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * @param \Exception $exception An Exception instance - */ function collect(Request $request, Response $response, \Exception $exception = null); - - /** - * Returns the name of the collector. - * - * @return string The collector name - */ function getName(); } -The value returned by ``getName()`` must be unique in the application. This value -is also used to access the information later on (see :doc:`/cookbook/testing/profiling` -for instance). - -The ``collect()`` method is responsible for storing the collected data in local -properties. +The +:method:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface::getName` +method returns the name of the data collector and must be unique in the +application. This value is also used to access the information later on (see +:doc:`/cookbook/testing/profiling` for instance). -.. caution:: - - As the profiler serializes data collector instances, you should not - store objects that cannot be serialized (like PDO objects), or you need - to provide your own ``serialize()`` method. +The +:method:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface::collect` +method is responsible for storing the collected data in local properties. Most of the time, it is convenient to extend :class:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector` and populate the ``$this->data`` property (it takes care of serializing the -``$this->data`` property):: +``$this->data`` property). Imagine you create a new data collector that +collects the method and accepted content types from the request:: + + // src/AppBundle/DataCollector/RequestCollector.php + namespace AppBundle\DataCollector; - // src/AppBundle/DataCollector/MyCollector.php use Symfony\Component\HttpKernel\DataCollector\DataCollector; - class MyCollector extends DataCollector + class RequestCollector extends DataCollector { public function collect(Request $request, Response $response, \Exception $exception = null) { $this->data = array( - 'variable' => 'value', + 'method' => $request->getMethod(), + 'acceptable_content_types' => $request->getAcceptableContentTypes(), ); } - public function getVariable() + public function getMethod() { - return $this->data['variable']; + return $this->data['method']; + } + + public function getAcceptableContentTypes() + { + return $this->data['acceptable_content_types']; } public function getName() { - return 'app.my_collector'; + return 'app.request_collector'; } } +The getters are added to give the template access to the collected information. + +.. caution:: + + As the profiler serializes data collector instances, you should not + store objects that cannot be serialized (like PDO objects) or you need + to provide your own ``serialize()`` method. + .. _data_collector_tag: Enabling Custom Data Collectors ------------------------------- -To enable a data collector, define it as a regular service and tag it with +To enable a data collector, define it as a regular service and tag it as ``data_collector``: .. configuration-block:: @@ -88,8 +89,8 @@ To enable a data collector, define it as a regular service and tag it with # app/config/services.yml services: - app.my_collector: - class: AppBundle\DataCollector\MyCollector + app.request_collector: + class: AppBundle\DataCollector\RequestCollector public: false tags: - { name: data_collector } @@ -104,8 +105,10 @@ To enable a data collector, define it as a regular service and tag it with http://symfony.com/schema/dic/services/services-1.0.xsd" > - + @@ -115,7 +118,7 @@ To enable a data collector, define it as a regular service and tag it with // app/config/services.php $container - ->register('app.my_collector', 'AppBundle\DataCollector\MyCollector') + ->register('app.request_collector', 'AppBundle\DataCollector\RequestCollector') ->setPublic(false) ->addTag('data_collector') ; @@ -139,24 +142,25 @@ block and set the value of two variables called ``icon`` and ``text``: {% set icon %} {# this is the content displayed as a panel in the toolbar #} - Information + Request {% endset %} {% set text %} {# this is the content displayed when hovering the mouse over the toolbar panel #}
- Quick piece of data - 100 units + Method + {{ collector.method }}
+
- Another piece of data - 300 units + Accepted content type + {{ collector.acceptablecontenttypes|join(', ') }}
{% endset %} {# the 'link' value set to 'false' means that this panel doesn't - show a section in the web profiler. #} + show a section in the web profiler (default is 'true'). #} {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false }) }} {% endblock %} @@ -190,7 +194,7 @@ must also define additional blocks: {% block toolbar %} {% set icon %} - Information + Request {% endset %} {% set text %} @@ -199,31 +203,36 @@ must also define additional blocks: {% endset %} - {# the 'link' value is now set to 'true', which allows the user to click - on it to access the web profiler panel. Since 'true' is the default - value, you can omit the 'link' parameter entirely #} - {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true }) }} + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig') }} {% endblock %} {% block head %} - {# Optional, you can here link to or define your own CSS and JS contents #} - {# {{ parent() }} to keep the default styles #} + {# Optional. Here you can link to or define your own CSS and JS contents. #} + {# Use {{ parent() }} to extend the default styles instead of overriding them. #} {% endblock %} {% block menu %} {# This left-hand menu appears when using the full-screen profiler. #} - Example Collector + Request {% endblock %} {% block panel %} {# Optional, for showing the most details. #} -

Example

-

- Major information goes here -

+

Acceptable Content Types

+ + + + + + {% for type in collector.acceptablecontenttypes %} + + + + {% endfor %} +
Content Type
{{ type }}
{% endblock %} The ``menu`` and ``panel`` blocks are the only required blocks to define the @@ -239,13 +248,13 @@ the ``data_collector`` tag in your service configuration: # app/config/services.yml services: - app.my_collector: - class: AppBundle\DataCollector\MyCollector + app.request_collector: + class: AppBundle\DataCollector\RequestCollector tags: - name: data_collector template: 'data_collector/template.html.twig' - id: 'app.my_collector' + id: 'app.request_collector' public: false .. code-block:: xml @@ -258,8 +267,14 @@ the ``data_collector`` tag in your service configuration: http://symfony.com/schema/dic/services/services-1.0.xsd" > - - + + @@ -268,11 +283,11 @@ the ``data_collector`` tag in your service configuration: // app/config/services.php $container - ->register('app.my_collector', 'AppBundle\DataCollector\MyCollector') + ->register('app.request_collector', 'AppBundle\DataCollector\RequestCollector') ->setPublic(false) ->addTag('data_collector', array( 'template' => 'data_collector/template.html.twig', - 'id' => 'app.my_collector', + 'id' => 'app.request_collector', )) ; @@ -290,15 +305,15 @@ want your collector to be displayed before them, use a higher value: # app/config/services.yml services: - app.my_collector: - class: AppBundle\DataCollector\MyCollector + app.request_collector: + class: AppBundle\DataCollector\RequestCollector tags: - { name: data_collector, template: '...', id: '...', priority: 300 } .. code-block:: xml - + @@ -306,7 +321,7 @@ want your collector to be displayed before them, use a higher value: // app/config/services.php $container - ->register('app.my_collector', 'AppBundle\DataCollector\MyCollector') + ->register('app.request_collector', 'AppBundle\DataCollector\RequestCollector') ->addTag('data_collector', array( 'template' => '...', 'id' => '...', From 30e0dd4462b95808135d4fc34444dea299319058 Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Mon, 12 Oct 2015 18:16:05 +0200 Subject: [PATCH 12/49] Added annotations example to Linking to Pages examples In the routing examples for the Linking to Pages section there were no annotations examples (which is what most people use). I have added these examples --- book/templating.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/book/templating.rst b/book/templating.rst index 832192aad7e..c70cad9accb 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -867,6 +867,20 @@ configuration: .. configuration-block:: + .. code-block:: php-annotations + + // src/AppBundle/Controller/WelcomeController.php + class WelcomeController extends Controller + { + /** + * @Route("/", name="_welcome") + */ + public function indexAction() + { + // ... + } + } + .. code-block:: yaml # app/config/routing.yml @@ -918,6 +932,20 @@ route: .. configuration-block:: + .. code-block:: php-annotations + + // src/AppBundle/Controller/ArticleController.php + class ArticleController extends Controller + { + /** + * @Route("/article/{slug}", name="article_show") + */ + public function showAction($slug) + { + // ... + } + } + .. code-block:: yaml # app/config/routing.yml From 05da6960a8a9c50a3b7600b5569790bdfc651b02 Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Wed, 14 Oct 2015 16:53:04 +0200 Subject: [PATCH 13/49] Added missing use statements Added missing use statements for new annotations code example --- book/templating.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/book/templating.rst b/book/templating.rst index c70cad9accb..01f0307b3ff 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -870,6 +870,9 @@ configuration: .. code-block:: php-annotations // src/AppBundle/Controller/WelcomeController.php + use Symfony\Bundle\FrameworkBundle\Controller\Controller; + use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; + class WelcomeController extends Controller { /** @@ -935,6 +938,9 @@ route: .. code-block:: php-annotations // src/AppBundle/Controller/ArticleController.php + use Symfony\Bundle\FrameworkBundle\Controller\Controller; + use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; + class ArticleController extends Controller { /** From 5941b89dbfdd0d0e7ad402ce40d0e27b25e83473 Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Wed, 14 Oct 2015 16:59:01 +0200 Subject: [PATCH 14/49] Remove indentation in blank line Remove indentation in blank line --- book/templating.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/templating.rst b/book/templating.rst index 01f0307b3ff..51abc36b4ee 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -872,7 +872,7 @@ configuration: // src/AppBundle/Controller/WelcomeController.php use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; - + class WelcomeController extends Controller { /** @@ -940,7 +940,7 @@ route: // src/AppBundle/Controller/ArticleController.php use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; - + class ArticleController extends Controller { /** From 4cc4baeef91dde5ba6336bf1568752d4f7b7a844 Mon Sep 17 00:00:00 2001 From: Benjamin Paap Date: Sun, 18 Oct 2015 18:49:18 +0200 Subject: [PATCH 15/49] Added documentation for dnsMessage option --- reference/constraints/Url.rst | 74 +++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index c33351d16cf..8702f567b18 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -10,6 +10,7 @@ Validates that a value is a valid URL string. | | - `protocols`_ | | | - `payload`_ | | | - `checkDNS`_ | +| | - `dnsMessage`_ +----------------+---------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Validator\\Constraints\\Url` | +----------------+---------------------------------------------------------------------+ @@ -299,5 +300,78 @@ option to ``true``: } } +dnsMessage +~~~~~~~~~~ + +.. versionadded:: 2.7 + The ``dnsMessage`` option was introduced in Symfony 2.7. + +**type**: ``string`` **default**: ``The host could not be resolved.`` + +This message is shown when the ``checkDNS`` option is set to ``true`` and the +DNS check failed. + +.. configuration-block:: + + .. code-block:: php-annotations + + // src/AppBundle/Entity/Author.php + namespace AppBundle\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + /** + * @Assert\Url( + * dnsMessage = "The host '{{ value }}' could not be resolved" + * ) + */ + protected $bioUrl; + } + + .. code-block:: yaml + + # src/AppBundle/Resources/config/validation.yml + AppBundle\Entity\Author: + properties: + bioUrl: + - Url: { dnsMessage: The host "{{ value }}" could not be resolved } + + .. code-block:: xml + + + + + + + + + + + + + + + .. code-block:: php + + // src/AppBundle/Entity/Author.php + namespace AppBundle\Entity; + + use Symfony\Component\Validator\Mapping\ClassMetadata; + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + public static function loadValidatorMetadata(ClassMetadata $metadata) + { + $metadata->addPropertyConstraint('bioUrl', new Assert\Url(array( + 'dnsMessage' => 'The host "{{ value }}" could not be resolved' + ))); + } + } + This option uses the :phpfunction:`checkdnsrr` PHP function to check the validity of the ``ANY`` DNS record corresponding to the host associated with the given URL. From f5774d21874d42764e32fa58844caea031e61e46 Mon Sep 17 00:00:00 2001 From: Diego Gullo Date: Sun, 18 Oct 2015 21:41:20 +0100 Subject: [PATCH 16/49] Changed 'in' to 'to' and removed 'composer' --- book/security.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/security.rst b/book/security.rst index 2f568aadadd..a9b075ee0a3 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1381,7 +1381,7 @@ FriendsOfPHP organization. .. note:: To enable the ``security:check`` command, you need to add the - `SensioDistributionBundle`_ in your composer dependencies. + `SensioDistributionBundle`_ to your dependencies. .. code-block:: bash From bffb90ddffddff44bf5a3bbf7f031b0061f4d1a8 Mon Sep 17 00:00:00 2001 From: Benjamin Paap Date: Mon, 19 Oct 2015 08:23:39 +0200 Subject: [PATCH 17/49] Fixed all comments from @xabbuh --- reference/constraints/Url.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 8702f567b18..694a93f05f6 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -10,7 +10,7 @@ Validates that a value is a valid URL string. | | - `protocols`_ | | | - `payload`_ | | | - `checkDNS`_ | -| | - `dnsMessage`_ +| | - `dnsMessage`_ | +----------------+---------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Validator\\Constraints\\Url` | +----------------+---------------------------------------------------------------------+ @@ -300,6 +300,9 @@ option to ``true``: } } +This option uses the :phpfunction:`checkdnsrr` PHP function to check the validity +of the ``ANY`` DNS record corresponding to the host associated with the given URL. + dnsMessage ~~~~~~~~~~ @@ -324,7 +327,7 @@ DNS check failed. { /** * @Assert\Url( - * dnsMessage = "The host '{{ value }}' could not be resolved" + * dnsMessage = "The host '{{ value }}' could not be resolved." * ) */ protected $bioUrl; @@ -336,7 +339,8 @@ DNS check failed. AppBundle\Entity\Author: properties: bioUrl: - - Url: { dnsMessage: The host "{{ value }}" could not be resolved } + - Url: + dnsMessage: 'The host "{{ value }}" could not be resolved.' .. code-block:: xml @@ -349,7 +353,7 @@ DNS check failed. - + @@ -368,10 +372,7 @@ DNS check failed. public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('bioUrl', new Assert\Url(array( - 'dnsMessage' => 'The host "{{ value }}" could not be resolved' + 'dnsMessage' => 'The host "{{ value }}" could not be resolved.' ))); } } - -This option uses the :phpfunction:`checkdnsrr` PHP function to check the validity -of the ``ANY`` DNS record corresponding to the host associated with the given URL. From 368576b9aeb6aba7e4ab096b812326b0fc962353 Mon Sep 17 00:00:00 2001 From: Benjamin Paap Date: Mon, 19 Oct 2015 08:27:10 +0200 Subject: [PATCH 18/49] Fixed Yaml syntax --- reference/constraints/Url.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 694a93f05f6..9248f2f320a 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -339,8 +339,7 @@ DNS check failed. AppBundle\Entity\Author: properties: bioUrl: - - Url: - dnsMessage: 'The host "{{ value }}" could not be resolved.' + - Url: { dnsMessage: 'The host "{{ value }}" could not be resolved.' } .. code-block:: xml From 02daba0438b7cfd1e78350ff543e60df9cc50ff0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 19 Oct 2015 11:22:31 +0200 Subject: [PATCH 19/49] Mentioned the BETA and RC support for the Symfony Installer --- book/installation.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/book/installation.rst b/book/installation.rst index 809fc914800..580425ed6fd 100644 --- a/book/installation.rst +++ b/book/installation.rst @@ -98,17 +98,17 @@ optional second argument of the ``new`` command: $ symfony new my_project_name 2.3.26 $ symfony new my_project_name 2.6.5 -If you want your project to be based on the latest :ref:`Symfony LTS version `, -pass ``lts`` as the second argument of the ``new`` command: + # use a beta or RC version (useful for testing new Symfony versions) + $ symfony new my_project 2.7.0-BETA1 + $ symfony new my_project 2.7.0-RC1 + +The installer also supports a special version called ``lts`` which installs the +most recent :ref:`Symfony LTS version ` available: .. code-block:: bash - # Linux, Mac OS X $ symfony new my_project_name lts - # Windows - c:\projects\> php symfony new my_project_name lts - Read the :doc:`Symfony Release process ` to better understand why there are several Symfony versions and which one to use for your projects. From 43f751e810f895f5b49dcf7f19addfcca07b7a6a Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Mon, 19 Oct 2015 12:17:06 +0200 Subject: [PATCH 20/49] Added missing namespace statements added the namespace statements to the annotation examples --- book/templating.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/book/templating.rst b/book/templating.rst index 51abc36b4ee..1370db8396b 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -870,6 +870,8 @@ configuration: .. code-block:: php-annotations // src/AppBundle/Controller/WelcomeController.php + namespace AppBundle\Controller; + use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; @@ -938,6 +940,8 @@ route: .. code-block:: php-annotations // src/AppBundle/Controller/ArticleController.php + namespace AppBundle\Controller; + use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; From e67beb2abe6b63c5736e6d1cc7a04ab5c8d34f2c Mon Sep 17 00:00:00 2001 From: Benjamin Paap Date: Mon, 19 Oct 2015 12:37:52 +0200 Subject: [PATCH 21/49] Added missing comma after array element --- reference/constraints/Url.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 9248f2f320a..14380b00f94 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -371,7 +371,7 @@ DNS check failed. public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('bioUrl', new Assert\Url(array( - 'dnsMessage' => 'The host "{{ value }}" could not be resolved.' + 'dnsMessage' => 'The host "{{ value }}" could not be resolved.', ))); } } From 3c37397678c538509029e37d50e0c57ac9077653 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 19 Oct 2015 15:35:17 +0200 Subject: [PATCH 22/49] Minor rewordings for the "deprecated" service option --- components/dependency_injection/advanced.rst | 24 +++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/components/dependency_injection/advanced.rst b/components/dependency_injection/advanced.rst index 58fde9ba615..3098bee9c24 100644 --- a/components/dependency_injection/advanced.rst +++ b/components/dependency_injection/advanced.rst @@ -226,8 +226,7 @@ Deprecating Services The ``deprecated`` setting was introduced in Symfony 2.8. Once you have decided to deprecate the use of a service (because it is outdated -or you decided not to use and maintain it anymore), you can deprecate its -definition: +or you decided not to maintain it anymore), you can deprecate its definition: .. configuration-block:: @@ -261,26 +260,25 @@ definition: ) ; -Now, every time a service is created using this deprecated definition, a -deprecation warning will be triggered, advising you to stop or to change your -uses of that service. +Now, every time this service is used, a deprecation warning is triggered, +advising you to stop or to change your uses of that service. -The message is actually a message template, which will replace occurrences -of the ``%service_id%`` by the service's id. You **must** have at least one +The message is actually a message template, which replaces occurrences of the +``%service_id%`` placeholder by the service's id. You **must** have at least one occurrence of the ``%service_id%`` placeholder in your template. .. note:: - The deprecation message is optional. If not set, Symfony will show a default - message ``The "%service_id%" service is deprecated. You should stop using it, + The deprecation message is optional. If not set, Symfony will show this default + message: ``The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.``. .. tip:: - It is strongly recommended that you fill the message template, to avoid a - message that could be too generic such as the default one. A good message - informs when this service was deprecated, and until when it will be - maintained (look at the examples above). + It is strongly recommended that you define a custom message because the + default one is too generic. A good message informs when this service was + deprecated, until when it will be maintained and the alternative services + to use (if any). For service decorators (see above), if the definition does not modify the deprecated status, it will inherit the status from the definition that is From 747f10b523ab804b3e8c8b01c3ccdd3b7537e6ca Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 19 Oct 2015 16:03:27 +0200 Subject: [PATCH 23/49] Reworded the explanation about flash messages --- book/controller.rst | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/book/controller.rst b/book/controller.rst index 1d15b914d7b..005569585ca 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -604,12 +604,13 @@ session. Flash Messages ~~~~~~~~~~~~~~ -You can also store small messages that will be stored on the user's session. -This is useful when processing a form: -you want to redirect and have a special message shown on the *next* page. -These types of messages are called "flash" messages. +You can also store special messages, called "flash" messages, on the user's +session. By design, flash messages are meant to be processed exactly once. This +means that they vanish from the session automatically as soon as they are +retrieved. This feature makes "flash" messages particularly suited for storing +user notifications. -For example, imagine you're processing a form submit:: +Consider the following form processing example:: use Symfony\Component\HttpFoundation\Request; @@ -633,12 +634,12 @@ For example, imagine you're processing a form submit:: return $this->render(...); } -After processing the request, the controller sets a ``notice`` flash message -in the session and then redirects. The name (``notice``) isn't significant - -it's just something you invent and reference next. +After processing the request, the controller sets a flash message in the session +and then redirects. The message key (``notice`` in this example) can be freely +chosen and is used to retrieve the message content. In the template of the next page (or even better, in your base layout template), -the following code will render the ``notice`` message: +the following code will render the messages stored under the ``notice`` key: .. configuration-block:: @@ -660,9 +661,9 @@ the following code will render the ``notice`` message: .. note:: - By design, flash messages are meant to be processed exactly once. This means - that they vanish from the session automatically when they are retrieved from - the flash bag by calling the ``get()`` method. + It's common to use ``notice``, ``warning`` and ``error` as the keys of the + different types of flash messages, but you can use any key that fits your + needs. .. tip:: From fa36ab944100e95f7efffe1fa2316cd916fe5832 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 19 Oct 2015 16:50:41 +0200 Subject: [PATCH 24/49] Minor fix --- book/templating.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/templating.rst b/book/templating.rst index 832192aad7e..f6a94f297ee 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -585,8 +585,8 @@ you set `with_context`_ to false). elements, it would look like this: ``{'foo': foo, 'bar': bar}``. .. versionadded:: 2.3 - The `include() function`_ is a new Twig feature that's available in Symfony - 2.3. Prior, the `{% include %} tag`_ tag was used. + The `include() function`_ is available since Symfony 2.3. Prior, the + `{% include %} tag`_ was used. .. index:: single: Templating; Embedding action From e38b0377699b9fbc2a734ff6e1171a90457b2407 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 20 Oct 2015 08:25:55 +0200 Subject: [PATCH 25/49] Fixed a RST syntax issue --- book/controller.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/controller.rst b/book/controller.rst index 005569585ca..4f634c9710d 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -661,7 +661,7 @@ the following code will render the messages stored under the ``notice`` key: .. note:: - It's common to use ``notice``, ``warning`` and ``error` as the keys of the + It's common to use ``notice``, ``warning`` and ``error`` as the keys of the different types of flash messages, but you can use any key that fits your needs. From f00efff224be443eed52c66b174270be8b064403 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 20 Oct 2015 11:53:45 +0200 Subject: [PATCH 26/49] use constants to choose generated URL type --- book/routing.rst | 6 +++++- book/templating.rst | 6 +++++- cookbook/controller/service.rst | 7 ++++++- cookbook/templating/render_without_controller.rst | 6 +++++- create_framework/routing.rst | 8 +++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/book/routing.rst b/book/routing.rst index 4476031a7c9..e128c5412e7 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -1499,9 +1499,13 @@ to ``generate()``: .. code-block:: html+php + + + ), UrlGeneratorInterface::ABSOLUTE_URL) ?>"> Read this blog post. diff --git a/book/templating.rst b/book/templating.rst index 832192aad7e..2391e195085 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -992,10 +992,14 @@ correctly: .. code-block:: html+php + + Home .. index:: diff --git a/cookbook/controller/service.rst b/cookbook/controller/service.rst index 5213004da20..50f91425be5 100644 --- a/cookbook/controller/service.rst +++ b/cookbook/controller/service.rst @@ -269,7 +269,12 @@ controller: :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::generateUrl` (service: ``router``) .. code-block:: php - $router->generate($route, $params, $absolute); + $router->generate($route, $params, $referenceType); + + .. note:: + + The ``$referenceType`` argument must be one of the constants defined + in the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface`. :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getDoctrine` (service: ``doctrine``) diff --git a/cookbook/templating/render_without_controller.rst b/cookbook/templating/render_without_controller.rst index cd9a6b8fc70..a3f35cd48e9 100644 --- a/cookbook/templating/render_without_controller.rst +++ b/cookbook/templating/render_without_controller.rst @@ -68,8 +68,12 @@ this is probably only useful if you'd like to cache this page partial (see .. code-block:: html+php + + render( - $view['router']->generate('acme_privacy', array(), true) + $view['router']->generate('acme_privacy', array(), UrlGeneratorInterface::ABSOLUTE_URL) ) ?> .. _cookbook-templating-no-controller-caching: diff --git a/create_framework/routing.rst b/create_framework/routing.rst index 7d84622e4c0..8a59ce83c8a 100644 --- a/create_framework/routing.rst +++ b/create_framework/routing.rst @@ -208,7 +208,13 @@ impact. Want to know how to use the generator? Insanely easy:: The code should be self-explanatory; and thanks to the context, you can even generate absolute URLs:: - echo $generator->generate('hello', array('name' => 'Fabien'), true); + use Symfony\Component\Routing\Generator\UrlGeneratorInterface; + + echo $generator->generate( + 'hello', + array('name' => 'Fabien'), + UrlGeneratorInterface::ABSOLUTE_URL + ); // outputs something like http://example.com/somewhere/hello/Fabien .. tip:: From 4e550ec82e892d9c3ddd8c7426b08c279a25ea27 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 20 Oct 2015 12:48:00 +0200 Subject: [PATCH 27/49] fix constraint names --- reference/constraints/map.rst.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/constraints/map.rst.inc b/reference/constraints/map.rst.inc index fefba07a30b..9ff2a7de7e4 100644 --- a/reference/constraints/map.rst.inc +++ b/reference/constraints/map.rst.inc @@ -7,9 +7,9 @@ the value of properties or the return value of methods on your object. * :doc:`NotBlank ` * :doc:`Blank ` * :doc:`NotNull ` -* :doc:`Null ` -* :doc:`True ` -* :doc:`False ` +* :doc:`IsNull ` +* :doc:`IsTrue ` +* :doc:`IsFalse ` * :doc:`Type ` String Constraints From ab19cfba7b24a660ea4239369ae4242ef2ee1496 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 20 Oct 2015 13:37:39 +0200 Subject: [PATCH 28/49] fix code block syntax --- book/controller.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/book/controller.rst b/book/controller.rst index 811364e8ecd..0ec4a592693 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -825,7 +825,9 @@ method to check the CSRF token:: .. versionadded:: 2.6 The ``isCsrfTokenValid()`` shortcut method was introduced in Symfony 2.6. - It is equivalent to executing the following code:: + It is equivalent to executing the following code: + + .. code-block:: php use Symfony\Component\Security\Csrf\CsrfToken; From 67edbe215b141cab95ca345462fc3798ead1f5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric?= Date: Thu, 15 Oct 2015 14:55:08 +0200 Subject: [PATCH 29/49] Callback Validation Constraint: Remove reference to deprecated option Regression from 2.6: http://symfony.com/doc/2.6/reference/constraints/Callback.html#external-callbacks-and-closures The examples were still using the old, deprecated syntax... And even calling a method not defined anymore (`isAuthorValid` instead of `validate`) --- reference/constraints/Callback.rst | 63 ++++++++++++------------------ 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index 6e419b512d3..7a11cc206de 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -193,7 +193,7 @@ You can then use the following configuration to invoke this validator: use Symfony\Component\Validator\Constraints as Assert; /** - * @Assert\Callback({"AppBundle\MyStaticValidatorClass", "isAuthorValid"}) + * @Assert\Callback({"Vendor\Package\Validator", "validate"}) */ class Author { @@ -201,36 +201,30 @@ You can then use the following configuration to invoke this validator: .. code-block:: yaml - # src/AppBundle/Resources/config/validation.yml - AppBundle\Entity\Author: - constraints: - - Callback: - methods: - - [AppBundle\MyStaticValidatorClass, isAuthorValid] + # src/AppBundle/Resources/config/validation.yml + AppBundle\Entity\Author: + constraints: + - Callback: [Vendor\Package\Validator, validate] .. code-block:: xml - - - - - - - - - - + + + + + + + Vendor\Package\Validator + validate + + + .. code-block:: php - // src/AppBundle/Entity/Author.php + // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; use Symfony\Component\Validator\Mapping\ClassMetadata; @@ -238,18 +232,12 @@ You can then use the following configuration to invoke this validator: class Author { - public $name; - public static function loadValidatorMetadata(ClassMetadata $metadata) { - $metadata->addConstraint(new Callback(array( - 'methods' => array( - array( - 'AppBundle\MyStaticValidatorClass', - 'isAuthorValid', - ), - ), - ))); + $metadata->addConstraint(new Assert\Callback(array( + 'Vendor\Package\Validator', + 'validate', + ))); } } @@ -267,8 +255,9 @@ constructor of the Callback constraint:: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; - use Symfony\Component\Validator\ExecutionContextInterface; - use AppBundle\Entity\Author; + use Symfony\Component\Validator\Context\ExecutionContextInterface; + // if you're using the older 2.4 validation API, you'll need this instead + // use Symfony\Component\Validator\ExecutionContextInterface; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Constraints as Assert; From ae600f999eecb993bb1707419ae41f6cacee13fb Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sat, 24 Oct 2015 16:17:34 +0200 Subject: [PATCH 30/49] Fixed whitelist delivery of swiftmailer --- reference/configuration/swiftmailer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/configuration/swiftmailer.rst b/reference/configuration/swiftmailer.rst index bae46b9ba33..3c0e9f938a1 100644 --- a/reference/configuration/swiftmailer.rst +++ b/reference/configuration/swiftmailer.rst @@ -164,7 +164,7 @@ delivery_whitelist **type**: ``array`` Used in combination with ``delivery_address``. If set, emails matching any -of these patterns will be delivered like normal, instead of being sent to +of these patterns will be delivered like normal, as well as being sent to ``delivery_address``. For details, see :ref:`the cookbook entry `. From 9392f806db727b9afa10e5b554adb97fa935ad26 Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sat, 24 Oct 2015 15:53:44 +0200 Subject: [PATCH 31/49] Updated CssSelector code example to use the new Converter --- components/css_selector.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/css_selector.rst b/components/css_selector.rst index 3935f3c85ee..8d5f0d658b5 100644 --- a/components/css_selector.rst +++ b/components/css_selector.rst @@ -47,11 +47,14 @@ The CssSelector Component ~~~~~~~~~~~~~~~~~~~~~~~~~ The component's only goal is to convert CSS selectors to their XPath -equivalents:: +equivalents, using :method:`Converter::toXPath() ` - use Symfony\Component\CssSelector\CssSelector; +.. code-block:: php - var_dump(CssSelector::toXPath('div.item > h4 > a')); + use Symfony\Component\CssSelector\Converter; + + $converter = new Converter(); + var_dump($converter->toXPath('div.item > h4 > a')); This gives the following output: From df4fc7ec58c4c233a9f27988131457ac29e5b8ac Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sun, 25 Oct 2015 10:40:02 +0100 Subject: [PATCH 32/49] Updated for CssSelectorConverter class name --- components/css_selector.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/css_selector.rst b/components/css_selector.rst index 8d5f0d658b5..d77fb89469f 100644 --- a/components/css_selector.rst +++ b/components/css_selector.rst @@ -47,13 +47,13 @@ The CssSelector Component ~~~~~~~~~~~~~~~~~~~~~~~~~ The component's only goal is to convert CSS selectors to their XPath -equivalents, using :method:`Converter::toXPath() ` +equivalents, using :method:`Symfony\\Component\\CssSelector\\CssSelectorConverter::toXPath` .. code-block:: php - use Symfony\Component\CssSelector\Converter; + use Symfony\Component\CssSelector\CssSelectorConverter; - $converter = new Converter(); + $converter = new CssSelectorConverter(); var_dump($converter->toXPath('div.item > h4 > a')); This gives the following output: From dfb9b16d3a0d6ac0a5b14ad1f5f345f27cc3fb24 Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sun, 25 Oct 2015 17:48:05 +0100 Subject: [PATCH 33/49] Used :: for code block --- components/css_selector.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/css_selector.rst b/components/css_selector.rst index d77fb89469f..588582fb371 100644 --- a/components/css_selector.rst +++ b/components/css_selector.rst @@ -47,9 +47,7 @@ The CssSelector Component ~~~~~~~~~~~~~~~~~~~~~~~~~ The component's only goal is to convert CSS selectors to their XPath -equivalents, using :method:`Symfony\\Component\\CssSelector\\CssSelectorConverter::toXPath` - -.. code-block:: php +equivalents, using :method:`Symfony\\Component\\CssSelector\\CssSelectorConverter::toXPath`:: use Symfony\Component\CssSelector\CssSelectorConverter; From 63e98245d695d287284f68096689eafae5f64819 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 5 Nov 2015 08:48:14 -0500 Subject: [PATCH 34/49] minor re-wording --- book/security.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/security.rst b/book/security.rst index a9b075ee0a3..27c66d2c751 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1380,8 +1380,8 @@ FriendsOfPHP organization. .. note:: - To enable the ``security:check`` command, you need to add the - `SensioDistributionBundle`_ to your dependencies. + To enable the ``security:check`` command, make sure the + `SensioDistributionBundle`_ is installed. .. code-block:: bash From c69b277cf3756da46b1549b4ddc37280eff049ac Mon Sep 17 00:00:00 2001 From: jls2933 Date: Wed, 9 Sep 2015 11:47:28 +0200 Subject: [PATCH 35/49] Update storage.rst --- cookbook/profiler/storage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/profiler/storage.rst b/cookbook/profiler/storage.rst index e91ef883eaa..04e8f3d815b 100644 --- a/cookbook/profiler/storage.rst +++ b/cookbook/profiler/storage.rst @@ -4,7 +4,7 @@ Switching the Profiler Storage ============================== -By default the profile stores the collected data in files in the cache directory. +By default the profile stores the collected data in files in the cache directory, under ``%kernel.cache_dir%/profiler``. You can control the storage being used through the ``dsn``, ``username``, ``password`` and ``lifetime`` options. For example, the following configuration uses MySQL as the storage for the profiler with a lifetime of one hour: From 1028d5fe911fb254841c3c024793ac909502750c Mon Sep 17 00:00:00 2001 From: jls2933 Date: Fri, 9 Oct 2015 19:23:57 +0200 Subject: [PATCH 36/49] Rewriting of the sentence. --- cookbook/profiler/storage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/profiler/storage.rst b/cookbook/profiler/storage.rst index 04e8f3d815b..c403ae36c51 100644 --- a/cookbook/profiler/storage.rst +++ b/cookbook/profiler/storage.rst @@ -4,7 +4,7 @@ Switching the Profiler Storage ============================== -By default the profile stores the collected data in files in the cache directory, under ``%kernel.cache_dir%/profiler``. +By default the profile stores the collected data in files in the ``%kernel.cache_dir%/profiler/`` directory. You can control the storage being used through the ``dsn``, ``username``, ``password`` and ``lifetime`` options. For example, the following configuration uses MySQL as the storage for the profiler with a lifetime of one hour: From 89c57e55aec1cc5725f8dc85d66187763dbec783 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 5 Nov 2015 11:54:50 -0500 Subject: [PATCH 37/49] rewording to Wouter's suggestion --- cookbook/security/custom_authentication_provider.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook/security/custom_authentication_provider.rst b/cookbook/security/custom_authentication_provider.rst index eaf9f7ffee6..dc5f3e4f8ba 100644 --- a/cookbook/security/custom_authentication_provider.rst +++ b/cookbook/security/custom_authentication_provider.rst @@ -354,8 +354,8 @@ requires the following methods: to the DI container for the appropriate security context. ``getPosition`` - Method which defines the position at which the provider is called. The - returned value must be one of ``pre_auth``, ``form``, ``http`` or ``remember_me``. + Returns when the provider should be called. This can be one of ``pre_auth``, + ``form``, ``http`` or ``remember_me``. ``getKey`` Method which defines the configuration key used to reference From 8b850204e36305a7ca076822de05a395ff703c61 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 5 Nov 2015 14:12:05 -0500 Subject: [PATCH 38/49] [#5774] fixing casing --- cookbook/profiler/data_collector.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook/profiler/data_collector.rst b/cookbook/profiler/data_collector.rst index b011bb878d4..f1d5d35abbb 100644 --- a/cookbook/profiler/data_collector.rst +++ b/cookbook/profiler/data_collector.rst @@ -155,7 +155,7 @@ block and set the value of two variables called ``icon`` and ``text``:
Accepted content type - {{ collector.acceptablecontenttypes|join(', ') }} + {{ collector.acceptableContentTypes|join(', ') }}
{% endset %} @@ -227,7 +227,7 @@ must also define additional blocks: Content Type - {% for type in collector.acceptablecontenttypes %} + {% for type in collector.acceptableContentTypes %} {{ type }} From bee92973d73719683da7635b9a28a17c9f5d80d6 Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Mon, 12 Oct 2015 18:04:11 +0200 Subject: [PATCH 39/49] Clarify when we are talking about PHP and Twig In the description for versioned URLs and absolute URLs for assets, it was not clear if we were talking about Twig or PHP. Also we are usually first talking about Twig and then PHP, not the other way around --- book/templating.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/book/templating.rst b/book/templating.rst index 245dd66210d..82b8ef5927c 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -1029,8 +1029,8 @@ configuration option. .. _`book-templating-version-by-asset`: -If you need to set a version for a specific asset, you can set the fourth -argument (or the ``version`` argument) to the desired version: +If you need to set a version for a specific asset, you can set the ``version`` argument +if you are using Twig (or the fourth argument if you are using PHP) to the desired version: .. configuration-block:: @@ -1051,8 +1051,8 @@ If you don't give a version or pass ``null``, the default package version (from :ref:`ref-framework-assets-version`) will be used. If you pass ``false``, versioned URL will be deactivated for this asset. -If you need absolute URLs for assets, you can set the third argument (or the -``absolute`` argument) to ``true``: +If you need absolute URLs for assets, you can set the ``absolute`` argument +if you are using Twig (or the third argument if you are using PHP) to ``true``: .. configuration-block:: From 43e440bf99db4d2671bd524f40bfd1507e65ab6a Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 5 Nov 2015 14:22:30 -0500 Subject: [PATCH 40/49] [#5781] Slightly shortening code block --- book/templating.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/book/templating.rst b/book/templating.rst index 1370db8396b..a4c046ef1ff 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -870,9 +870,8 @@ configuration: .. code-block:: php-annotations // src/AppBundle/Controller/WelcomeController.php - namespace AppBundle\Controller; + // ... - use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; class WelcomeController extends Controller @@ -940,9 +939,8 @@ route: .. code-block:: php-annotations // src/AppBundle/Controller/ArticleController.php - namespace AppBundle\Controller; + // ... - use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; class ArticleController extends Controller From ef7061fb2e74333321ebc6989ea845fcbfc0a8fc Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 5 Nov 2015 14:43:09 -0500 Subject: [PATCH 41/49] [#5808] Language tweaks as a I read - Javier improves my language, then I tweak things a little further :) --- book/controller.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/book/controller.rst b/book/controller.rst index 4f634c9710d..49cc0ba9907 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -605,12 +605,11 @@ Flash Messages ~~~~~~~~~~~~~~ You can also store special messages, called "flash" messages, on the user's -session. By design, flash messages are meant to be processed exactly once. This -means that they vanish from the session automatically as soon as they are -retrieved. This feature makes "flash" messages particularly suited for storing -user notifications. +session. By design, flash messages are meant to be used exactly once: they vanish +from the session automatically as soon as you retrieve them. This feature makes +"flash" messages particularly great for storing user notifications. -Consider the following form processing example:: +For example, imagine you're processing a form submission:: use Symfony\Component\HttpFoundation\Request; @@ -635,19 +634,19 @@ Consider the following form processing example:: } After processing the request, the controller sets a flash message in the session -and then redirects. The message key (``notice`` in this example) can be freely -chosen and is used to retrieve the message content. +and then redirects. The message key (``notice`` in this example) can be anything: +you'll use this key to retrieve the message. In the template of the next page (or even better, in your base layout template), -the following code will render the messages stored under the ``notice`` key: +read any flash messages from the session:: .. configuration-block:: .. code-block:: html+jinja - {% for flashMessage in app.session.flashbag.get('notice') %} + {% for flash_message in app.session.flashbag.get('notice') %}
- {{ flashMessage }} + {{ flash_message }}
{% endfor %} From ece53b8cd0520e895c72bcc5f5cb32bb7a3cfe6c Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Thu, 22 Oct 2015 12:21:01 +0200 Subject: [PATCH 42/49] "setup" is a noun or adjective, "set up" is the verb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, I donĀ“t see any need for this to be capitalized --- cookbook/event_dispatcher/before_after_filters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/event_dispatcher/before_after_filters.rst b/cookbook/event_dispatcher/before_after_filters.rst index 2b7d25d6a9d..40d578cd1b4 100644 --- a/cookbook/event_dispatcher/before_after_filters.rst +++ b/cookbook/event_dispatcher/before_after_filters.rst @@ -1,7 +1,7 @@ .. index:: single: EventDispatcher -How to Setup before and after Filters +How to set up before and after Filters ===================================== It is quite common in web application development to need some logic to be From 50c701095045bb996d6010aeadc0fb587221b09f Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Thu, 22 Oct 2015 12:45:10 +0200 Subject: [PATCH 43/49] Changed to title capitalization --- cookbook/event_dispatcher/before_after_filters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/event_dispatcher/before_after_filters.rst b/cookbook/event_dispatcher/before_after_filters.rst index 40d578cd1b4..12eb2d75f66 100644 --- a/cookbook/event_dispatcher/before_after_filters.rst +++ b/cookbook/event_dispatcher/before_after_filters.rst @@ -1,7 +1,7 @@ .. index:: single: EventDispatcher -How to set up before and after Filters +How to Set up before and after Filters ===================================== It is quite common in web application development to need some logic to be From 5c1b3d4d228cdccafb477c61040d82f94061c57e Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Thu, 22 Oct 2015 12:51:14 +0200 Subject: [PATCH 44/49] Update title capitalization --- cookbook/event_dispatcher/before_after_filters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/event_dispatcher/before_after_filters.rst b/cookbook/event_dispatcher/before_after_filters.rst index 12eb2d75f66..2543a9f1529 100644 --- a/cookbook/event_dispatcher/before_after_filters.rst +++ b/cookbook/event_dispatcher/before_after_filters.rst @@ -1,7 +1,7 @@ .. index:: single: EventDispatcher -How to Set up before and after Filters +How to Set Up Before and After Filters ===================================== It is quite common in web application development to need some logic to be From 909fab2ec5e5b5fcaf06d76917853639b7904864 Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Thu, 22 Oct 2015 12:53:26 +0200 Subject: [PATCH 45/49] Fix title underlining --- cookbook/event_dispatcher/before_after_filters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/event_dispatcher/before_after_filters.rst b/cookbook/event_dispatcher/before_after_filters.rst index 2543a9f1529..9420674a39e 100644 --- a/cookbook/event_dispatcher/before_after_filters.rst +++ b/cookbook/event_dispatcher/before_after_filters.rst @@ -2,7 +2,7 @@ single: EventDispatcher How to Set Up Before and After Filters -===================================== +====================================== It is quite common in web application development to need some logic to be executed just before or just after your controller actions acting as filters From 532b0a4fa312bcb0d15c7f3e446102c2cc2d5845 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 5 Nov 2015 14:54:23 -0500 Subject: [PATCH 46/49] [#5835] Added versionadded --- components/css_selector.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/css_selector.rst b/components/css_selector.rst index 588582fb371..b01de07013f 100644 --- a/components/css_selector.rst +++ b/components/css_selector.rst @@ -46,6 +46,10 @@ document. The CssSelector Component ~~~~~~~~~~~~~~~~~~~~~~~~~ +.. versionadded:: 2.8 + The ``CssSelectorConverter`` class was introduced in Symfony 2.8. Previously, + the ``CssSelector`` class was used and ``toXPath`` was a static method. + The component's only goal is to convert CSS selectors to their XPath equivalents, using :method:`Symfony\\Component\\CssSelector\\CssSelectorConverter::toXPath`:: From 5ebb83375a870917563b25c5de0c0d91ed4ce237 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Thu, 29 Oct 2015 17:51:32 +0100 Subject: [PATCH 47/49] Clarified ambiguous wording In this context, "even" can be misunderstood as "actually". --- components/dom_crawler.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 8e356c3e95d..8ccd3660689 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -87,7 +87,7 @@ Anonymous function can be used to filter with more complex criteria:: $crawler = $crawler ->filter('body > p') ->reduce(function (Crawler $node, $i) { - // filter even nodes + // filter every second node return ($i % 2) == 0; }); From 90f5621dffd7a9801aa98e0943b61308fdbc03e1 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Sun, 1 Nov 2015 21:18:23 +0100 Subject: [PATCH 48/49] Update dom_crawler.rst --- components/dom_crawler.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 8ccd3660689..63efa9f8223 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -87,7 +87,7 @@ Anonymous function can be used to filter with more complex criteria:: $crawler = $crawler ->filter('body > p') ->reduce(function (Crawler $node, $i) { - // filter every second node + // filter every other node return ($i % 2) == 0; }); From 758e5c93a0598dfeacfa982c061a3fb72eacea8b Mon Sep 17 00:00:00 2001 From: artf Date: Thu, 5 Nov 2015 21:48:38 +0100 Subject: [PATCH 49/49] Fixed little typo with a twig example Was stuck with this throw: Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\FormRenderer::searchAndRenderBlock() must be an instance of Symfony\Component\Form\FormView, string given, called in.... --- cookbook/doctrine/registration_form.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cookbook/doctrine/registration_form.rst b/cookbook/doctrine/registration_form.rst index eae59327298..81be0c42b17 100644 --- a/cookbook/doctrine/registration_form.rst +++ b/cookbook/doctrine/registration_form.rst @@ -298,10 +298,10 @@ Next, create the template: {# app/Resources/views/registration/register.html.twig #} {{ form_start(form) }} - {{ form_row('form.username') }} - {{ form_row('form.email') }} - {{ form_row('form.plainPassword.first') }} - {{ form_row('form.plainPassword.second') }} + {{ form_row(form.username) }} + {{ form_row(form.email) }} + {{ form_row(form.plainPassword.first) }} + {{ form_row(form.plainPassword.second) }} {{ form_end(form) }}