From 2b0213b365f2f11e6c8db324f093280d5248512d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 26 May 2014 13:26:44 +0200 Subject: [PATCH 01/12] Added a note about customizing a form with more than one template --- cookbook/form/form_customization.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/cookbook/form/form_customization.rst b/cookbook/form/form_customization.rst index 554816a1f67..df0f39075d5 100644 --- a/cookbook/form/form_customization.rst +++ b/cookbook/form/form_customization.rst @@ -298,6 +298,33 @@ When the ``form.age`` widget is rendered, Symfony will use the ``integer_widget` block from the new template and the ``input`` tag will be wrapped in the ``div`` element specified in the customized block. +Multiple templates +.................. + +A form can also be customized applying several templates. To do so, pass the +name of all the templates to the ``form_theme`` tag separating them with one +whitespace: + +.. code-block:: html+jinja + + {% form_theme form '::common.html.twig' ':Form:fields.html.twig' + 'AcmeDemoBundle:Form:fields.html.twig' %} + + {# ... #} + +The templates can be located at different bundles and they can even be stored +at the global ``app/Resources/views/`` directory. + +When using the ``with`` keyword, pass the templates as an array: + + +.. code-block:: html+jinja + + {% form_theme form with ['::common.html.twig', ':Form:fields.html.twig', + 'AcmeDemoBundle:Form:fields.html.twig'] %} + + {# ... #} + Child Forms ........... From 6621720cd5361a5ed22896799b457a6d95f48bc5 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 26 May 2014 13:29:30 +0200 Subject: [PATCH 02/12] Minor formatting improvement --- cookbook/form/form_customization.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/form/form_customization.rst b/cookbook/form/form_customization.rst index df0f39075d5..20dd97310d4 100644 --- a/cookbook/form/form_customization.rst +++ b/cookbook/form/form_customization.rst @@ -321,7 +321,7 @@ When using the ``with`` keyword, pass the templates as an array: .. code-block:: html+jinja {% form_theme form with ['::common.html.twig', ':Form:fields.html.twig', - 'AcmeDemoBundle:Form:fields.html.twig'] %} + 'AcmeDemoBundle:Form:fields.html.twig'] %} {# ... #} From 94625c5c4d44f2fb3e0629506fc72ca7c6917e03 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 26 May 2014 15:34:11 +0200 Subject: [PATCH 03/12] Fixed minor formatting issue --- cookbook/form/form_customization.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/form/form_customization.rst b/cookbook/form/form_customization.rst index 20dd97310d4..63b880dc0ca 100644 --- a/cookbook/form/form_customization.rst +++ b/cookbook/form/form_customization.rst @@ -298,7 +298,7 @@ When the ``form.age`` widget is rendered, Symfony will use the ``integer_widget` block from the new template and the ``input`` tag will be wrapped in the ``div`` element specified in the customized block. -Multiple templates +Multiple Templates .................. A form can also be customized applying several templates. To do so, pass the From 08d26ee18f856ccbf0f22846c418a24b5c0da804 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Jun 2014 22:29:20 +0200 Subject: [PATCH 04/12] Removed the old syntax and left just the "with" keyword syntax --- cookbook/form/form_customization.rst | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/cookbook/form/form_customization.rst b/cookbook/form/form_customization.rst index 63b880dc0ca..f43800e762e 100644 --- a/cookbook/form/form_customization.rst +++ b/cookbook/form/form_customization.rst @@ -302,29 +302,18 @@ Multiple Templates .................. A form can also be customized applying several templates. To do so, pass the -name of all the templates to the ``form_theme`` tag separating them with one -whitespace: +name of all the templates as an array using the ``with`` keyword: .. code-block:: html+jinja - {% form_theme form '::common.html.twig' ':Form:fields.html.twig' - 'AcmeDemoBundle:Form:fields.html.twig' %} + {% form_theme form with ['::common.html.twig', ':Form:fields.html.twig', + 'AcmeDemoBundle:Form:fields.html.twig'] %} {# ... #} The templates can be located at different bundles and they can even be stored at the global ``app/Resources/views/`` directory. -When using the ``with`` keyword, pass the templates as an array: - - -.. code-block:: html+jinja - - {% form_theme form with ['::common.html.twig', ':Form:fields.html.twig', - 'AcmeDemoBundle:Form:fields.html.twig'] %} - - {# ... #} - Child Forms ........... From 1b386fff89e4990e777747f660a48f559798a0b1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 11 Jun 2014 08:46:53 +0200 Subject: [PATCH 05/12] Fixed a minor error --- cookbook/form/form_customization.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/form/form_customization.rst b/cookbook/form/form_customization.rst index f43800e762e..343edadfcdc 100644 --- a/cookbook/form/form_customization.rst +++ b/cookbook/form/form_customization.rst @@ -301,7 +301,7 @@ block from the new template and the ``input`` tag will be wrapped in the Multiple Templates .................. -A form can also be customized applying several templates. To do so, pass the +A form can also be customized applying several templates. To do this, pass the name of all the templates as an array using the ``with`` keyword: .. code-block:: html+jinja From d64fc55f567a69fa81eeeca84d7f262959aecdf8 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 3 Jul 2014 15:31:22 -0500 Subject: [PATCH 06/12] Move the section about collect: false to the cookbook entry This keeps the chapter shorter --- book/testing.rst | 46 ------------------------------- cookbook/testing/profiling.rst | 49 ++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/book/testing.rst b/book/testing.rst index e868b01c85d..7a62022a1f8 100644 --- a/book/testing.rst +++ b/book/testing.rst @@ -480,52 +480,6 @@ To get the Profiler for the last request, do the following:: For specific details on using the profiler inside a test, see the :doc:`/cookbook/testing/profiling` cookbook entry. -To avoid collecting data in each test you can set the ``collect`` parameter -in the configuration: - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/config_test.yml - - # ... - framework: - profiler: - enabled: true - collect: false - - .. code-block:: xml - - - - - - - - - - - - - .. code-block:: php - - // app/config/config.php - - // ... - $container->loadFromExtension('framework', array( - 'profiler' => array( - 'enabled' => true, - 'collect' => false, - ), - )); - -In this way only tests that call ``enableProfiler()`` will collect data. - Redirecting ~~~~~~~~~~~ diff --git a/cookbook/testing/profiling.rst b/cookbook/testing/profiling.rst index 5dacddb0837..613e997629f 100644 --- a/cookbook/testing/profiling.rst +++ b/cookbook/testing/profiling.rst @@ -73,3 +73,52 @@ finish. It's easy to achieve if you embed the token in the error message:: Read the API for built-in :doc:`data collectors ` to learn more about their interfaces. + +Speeding up Tests by not Collecting Profiler Data +------------------------------------------------- + +To avoid collecting data in each test you can set the ``collect`` parameter +to false: + +.. configuration-block:: + + .. code-block:: yaml + + # app/config/config_test.yml + + # ... + framework: + profiler: + enabled: true + collect: false + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // app/config/config.php + + // ... + $container->loadFromExtension('framework', array( + 'profiler' => array( + 'enabled' => true, + 'collect' => false, + ), + )); + +In this way only tests that call ``$client->enableProfiler()`` will collect data. From 52eeec40662345d0a734921e7a8b33d795248e44 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Fri, 23 May 2014 02:44:58 -0500 Subject: [PATCH 07/12] plug rules for static methods --- contributing/code/bc.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contributing/code/bc.rst b/contributing/code/bc.rst index 0e55eb2d18f..2d2a5f9cc94 100644 --- a/contributing/code/bc.rst +++ b/contributing/code/bc.rst @@ -138,7 +138,7 @@ 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 ugprade instructions in the UPGRADE + 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`` @@ -307,6 +307,9 @@ 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 +**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 From 9207f68a21b89a6417c50a94bcb154d597f05c81 Mon Sep 17 00:00:00 2001 From: Vincent Composieux Date: Sat, 5 Jul 2014 12:57:33 +0200 Subject: [PATCH 08/12] [Console] Fix Console component getHelperSet()->get() to getHelper() --- components/console/helpers/dialoghelper.rst | 10 +++++----- components/console/helpers/formatterhelper.rst | 2 +- components/console/helpers/progresshelper.rst | 2 +- components/console/helpers/tablehelper.rst | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/console/helpers/dialoghelper.rst b/components/console/helpers/dialoghelper.rst index 2cabf66df31..9b2d0363839 100644 --- a/components/console/helpers/dialoghelper.rst +++ b/components/console/helpers/dialoghelper.rst @@ -9,7 +9,7 @@ functions to ask the user for more information. It is included in the default helper set, which you can get by calling :method:`Symfony\\Component\\Console\\Command\\Command::getHelperSet`:: - $dialog = $this->getHelperSet()->get('dialog'); + $dialog = $this->getHelper('dialog'); All the methods inside the Dialog Helper have an :class:`Symfony\\Component\\Console\\Output\\OutputInterface` as the first @@ -65,7 +65,7 @@ Autocompletion You can also specify an array of potential answers for a given question. These will be autocompleted as the user types:: - $dialog = $this->getHelperSet()->get('dialog'); + $dialog = $this->getHelper('dialog'); $bundleNames = array('AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle'); $name = $dialog->ask( $output, @@ -83,7 +83,7 @@ Hiding the User's Response You can also ask a question and hide the response. This is particularly convenient for passwords:: - $dialog = $this->getHelperSet()->get('dialog'); + $dialog = $this->getHelper('dialog'); $password = $dialog->askHiddenResponse( $output, 'What is the database password?', @@ -154,7 +154,7 @@ Validating a Hidden Response You can also ask and validate a hidden response:: - $dialog = $this->getHelperSet()->get('dialog'); + $dialog = $this->getHelper('dialog'); $validator = function ($value) { if ('' === trim($value)) { @@ -192,7 +192,7 @@ Instead, you can use the method, which makes sure that the user can only enter a valid string from a predefined list:: - $dialog = $this->getHelperSet()->get('dialog'); + $dialog = $this->getHelper('dialog'); $colors = array('red', 'blue', 'yellow'); $color = $dialog->select( diff --git a/components/console/helpers/formatterhelper.rst b/components/console/helpers/formatterhelper.rst index 565be6e6bab..12386d04c3f 100644 --- a/components/console/helpers/formatterhelper.rst +++ b/components/console/helpers/formatterhelper.rst @@ -12,7 +12,7 @@ The :class:`Symfony\\Component\\Console\\Helper\\FormatterHelper` is included in the default helper set, which you can get by calling :method:`Symfony\\Component\\Console\\Command\\Command::getHelperSet`:: - $formatter = $this->getHelperSet()->get('formatter'); + $formatter = $this->getHelper('formatter'); The methods return a string, which you'll usually render to the console by passing it to the diff --git a/components/console/helpers/progresshelper.rst b/components/console/helpers/progresshelper.rst index 0447acec461..ee0366dd287 100644 --- a/components/console/helpers/progresshelper.rst +++ b/components/console/helpers/progresshelper.rst @@ -18,7 +18,7 @@ information, which updates as your command runs: To display progress details, use the :class:`Symfony\\Component\\Console\\Helper\\ProgressHelper`, pass it a total number of units, and advance the progress as your command executes:: - $progress = $this->getHelperSet()->get('progress'); + $progress = $this->getHelper('progress'); $progress->start($output, 50); $i = 0; diff --git a/components/console/helpers/tablehelper.rst b/components/console/helpers/tablehelper.rst index 2445c02da7f..537c7674270 100644 --- a/components/console/helpers/tablehelper.rst +++ b/components/console/helpers/tablehelper.rst @@ -14,7 +14,7 @@ When building a console application it may be useful to display tabular data: To display a table, use the :class:`Symfony\\Component\\Console\\Helper\\TableHelper`, set headers, rows and render:: - $table = $this->getHelperSet()->get('table'); + $table = $this->getHelper('table'); $table ->setHeaders(array('ISBN', 'Title', 'Author')) ->setRows(array( From ce1410461875f147b76b0fbca6457b69ffeb25eb Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 5 Jul 2014 15:33:52 +0200 Subject: [PATCH 09/12] Fixed a minor grammar mistake --- cookbook/form/form_customization.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/form/form_customization.rst b/cookbook/form/form_customization.rst index 343edadfcdc..3436715cc59 100644 --- a/cookbook/form/form_customization.rst +++ b/cookbook/form/form_customization.rst @@ -301,7 +301,7 @@ block from the new template and the ``input`` tag will be wrapped in the Multiple Templates .................. -A form can also be customized applying several templates. To do this, pass the +A form can also be customized by applying several templates. To do this, pass the name of all the templates as an array using the ``with`` keyword: .. code-block:: html+jinja From 755b1c1fb2dc9272aeff585a7f17406805321695 Mon Sep 17 00:00:00 2001 From: Raul Fraile Date: Mon, 7 Apr 2014 16:46:31 +0200 Subject: [PATCH 10/12] Fix function example in expression language component The is_string check needs to be part of the runtime code, not of the compilation code, because it needs to check that the argument is a string, not the compiled code to access it (which is always a string as it is source code --- components/expression_language/extending.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/expression_language/extending.rst b/components/expression_language/extending.rst index e2678236d17..56147de15d8 100644 --- a/components/expression_language/extending.rst +++ b/components/expression_language/extending.rst @@ -35,11 +35,7 @@ This method has 3 arguments: $language = new ExpressionLanguage(); $language->register('lowercase', function ($str) { - if (!is_string($str)) { - return $str; - } - - return sprintf('strtolower(%s)', $str); + return sprintf('$result = (is_string(%1$s)) ? strtolower(%1$s) : %1$s; return $result;', $str); }, function ($arguments, $str) { if (!is_string($str)) { return $str; From 235cf33466dd299ef5bc3d250cabfeea090062d3 Mon Sep 17 00:00:00 2001 From: Raul Fraile Date: Thu, 3 Jul 2014 23:14:42 +0200 Subject: [PATCH 11/12] Removed return statement --- components/expression_language/extending.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/expression_language/extending.rst b/components/expression_language/extending.rst index 56147de15d8..94762110bcd 100644 --- a/components/expression_language/extending.rst +++ b/components/expression_language/extending.rst @@ -35,7 +35,7 @@ This method has 3 arguments: $language = new ExpressionLanguage(); $language->register('lowercase', function ($str) { - return sprintf('$result = (is_string(%1$s)) ? strtolower(%1$s) : %1$s; return $result;', $str); + is_string(%1$s) ? strtolower(%1$s) : %1$s; }, function ($arguments, $str) { if (!is_string($str)) { return $str; From dfcdcbdadbf89971b10a41c9ee7f3235000b5fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 27 May 2014 11:06:48 +0200 Subject: [PATCH 12/12] document the mysterious abc part of the header One can't help but wonder what it is about. --- cookbook/cache/varnish.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cookbook/cache/varnish.rst b/cookbook/cache/varnish.rst index da06add99f1..7dd46d9a11f 100644 --- a/cookbook/cache/varnish.rst +++ b/cookbook/cache/varnish.rst @@ -38,6 +38,11 @@ application: set req.http.Surrogate-Capability = "abc=ESI/1.0"; } +.. note:: + + The ``abc`` part of the header isn't important unless you have multiple "surrogates" + that need to advertise their capabilities. See `Surrogate-Capability Header`_ for details. + Then, optimize Varnish so that it only parses the Response contents when there is at least one ESI tag by checking the ``Surrogate-Control`` header that Symfony2 adds automatically: @@ -217,3 +222,4 @@ absolute URLs: .. _`Varnish`: https://www.varnish-cache.org .. _`Edge Architecture`: http://www.w3.org/TR/edge-arch .. _`GZIP and Varnish`: https://www.varnish-cache.org/docs/3.0/phk/gzip.html +.. _`Surrogate-Capability Header`: http://www.w3.org/TR/edge-arch