8000 Merge branch '2.5' · damienalexandre/symfony-docs@5946be6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5946be6

Browse files
committed
Merge branch '2.5'
* 2.5: document the mysterious abc part of the header Removed return statement Fix function example in expression language component [Console] Fixed QuestionHelper examples Fixed a minor grammar mistake [Console] Fix Console component getHelperSet()->get() to getHelper() [Console] Fix Con 10000 sole some $app to $this and getHelperSet()->get() to getHelper() plug rules for static methods Move the section about collect: false to the cookbook entry Fixed a minor error Removed the old syntax and left just the "with" keyword syntax Fixed minor formatting issue Minor formatting improvement Added a note about customizing a form with more than one template
2 parents 2ae4f34 + 21e1df6 commit 5946be6

File tree

11 files changed

+95
-68
lines changed

11 files changed

+95
-68
lines changed

book/testing.rst

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -487,52 +487,6 @@ To get the Profiler for the last request, do the following::
487487
For specific details on using the profiler inside a test, see the
488488
:doc:`/cookbook/testing/profiling` cookbook entry.
489489

490-
To avoid collecting data in each test you can set the ``collect`` parameter
491-
in the configuration:
492-
493-
.. configuration-block::
494-
495-
.. code-block:: yaml
496-
497-
# app/config/config_test.yml
498-
499-
# ...
500-
framework:
501-
profiler:
502-
enabled: true
503-
collect: false
504-
505-
.. code-block:: xml
506-
507-
<!-- app/config/config.xml -->
508-
<?xml version="1.0" encoding="UTF-8" ?>
509-
<container xmlns="http://symfony.com/schema/dic/services"
510-
xmlns:framework="http://symfony.com/schema/dic/symfony"
511-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
512-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
513-
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
514-
515-
<!-- ... -->
516-
517-
<framework:config>
518-
<framework:profiler enabled="true" collect="false" />
519-
</framework:config>
520-
</container>
521-
522-
.. code-block:: php
523-
524-
// app/config/config.php
525-
526-
// ...
527-
$container->loadFromExtension('framework', array(
528-
'profiler' => array(
529-
'enabled' => true,
530-
'collect' => false,
531-
),
532-
));
533-
534-
In this way only tests that call ``enableProfiler()`` will collect data.
535-
536490
Redirecting
537491
~~~~~~~~~~~
538492

components/console/helpers/dialoghelper.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ functions to ask the user for more information. It is included in the default
1616
helper set, which you can get by calling
1717
:method:`Symfony\\Component\\Console\\Command\\Command::getHelperSet`::
1818

19-
$dialog = $this->getHelperSet()->get('dialog');
19+
$dialog = $this->getHelper('dialog');
2020

2121
All the methods inside the Dialog Helper have an
2222
:class:`Symfony\\Component\\Console\\Output\\OutputInterface` as the first
@@ -69,7 +69,7 @@ Autocompletion
6969
You can also specify an array of potential answers for a given question. These
7070
will be autocompleted as the user types::
7171

72-
$dialog = $this->getHelperSet()->get('dialog');
72+
$dialog = $this->getHelper('dialog');
7373
$bundleNames = array('AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle');
7474
$name = $dialog->ask(
7575
$output,
@@ -84,7 +84,7 @@ Hiding the User's Response
8484
You can also ask a question and hide the response. This is particularly
8585
convenient for passwords::
8686

87-
$dialog = $this->getHelperSet()->get('dialog');
87+
$dialog = $this->getHelper('dialog');
8888
$password = $dialog->askHiddenResponse(
8989
$output,
9090
'What is the database password?',
@@ -152,7 +152,7 @@ Validating a Hidden Response
152152

153153
You can also ask and validate a hidden response::
154154

155-
$dialog = $this->getHelperSet()->get('dialog');
155+
$dialog = $this->getHelper('dialog');
156156

157157
$validator = function ($value) {
158158
if ('' === trim($value)) {
@@ -186,7 +186,7 @@ Instead, you can use the
186186
method, which makes sure that the user can only enter a valid string
187187
from a predefined list::
188188

189-
$dialog = $this->getHelperSet()->get('dialog');
189+
$dialog = $this->getHelper('dialog');
190190
$colors = array('red', 'blue', 'yellow');
191191

192192
$color = $dialog->select(

components/console/helpers/formatterhelper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The :class:`Symfony\\Component\\Console\\Helper\\FormatterHelper` is included
1212
in the default helper set, which you can get by calling
1313
:method:`Symfony\\Component\\Console\\Command\\Command::getHelperSet`::
1414

15-
$formatter = $this->getHelperSet()->get('formatter');
15+
$formatter = $this->getHelper('formatter');
1616

1717
The methods return a string, which you'll usually render to the console by
1818
passing it to the

components/console/helpers/progresshelper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ information, which updates as your command runs:
2525
To display progress details, use the :class:`Symfony\\Component\\Console\\Helper\\ProgressHelper`,
2626
pass it a total number of units, and advance the progress as your command executes::
2727

28-
$progress = $this->getHelperSet()->get('progress');
28+
$progress = $this->getHelper('progress');
2929

3030
$progress->start($output, 50);
3131
$i = 0;

components/console/helpers/questionhelper.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ functions to ask the user for more information. It is included in the default
1212
helper set, which you can get by calling
1313
:method:`Symfony\\Component\\Console\\Command\\Command::getHelperSet`::
1414

15-
$helper = $this->getHelperSet()->get('question');
15+
$helper = $this->getHelper('question');
1616

1717
The Question Helper has a single method
1818
:method:`Symfony\\Component\\Console\\Command\\Command::ask` that needs an
@@ -30,7 +30,7 @@ the following to your command::
3030
use Symfony\Component\Console\Question\ConfirmationQuestion;
3131
// ...
3232

33-
$helper = $this->getHelperSet()->get('question');
33+
$helper = $this->getHelper('question');
3434
$question = new ConfirmationQuestion('Continue with this action?', false);
3535

3636
if (!$helper->ask($input, $output, $question)) {
@@ -73,11 +73,11 @@ from a predefined list::
7373
use Symfony\Component\Console\Question\ChoiceQuestion;
7474
// ...
7575

76-
$helper = $app->getHelperSet()->get('question');
76+
$helper = $this->getHelper('question');
7777
$question = new ChoiceQuestion(
7878
'Please select your favorite color (defaults to red)',
7979
array('red', 'blue', 'yellow'),
80-
'red'
80+
0
8181
);
8282
$question->setErrorMessage('Color %s is invalid.');
8383

@@ -107,11 +107,11 @@ this use :method:`Symfony\\Component\\Console\\Question\\ChoiceQuestion::setMult
107107
use Symfony\Component\Console\Question\ChoiceQuestion;
108108
// ...
109109

110-
$helper = $app->getHelperSet()->get('question');
110+
$helper = $this->getHelper('question');
111111
$question = new ChoiceQuestion(
112-
'Please select your favorite color (defaults to red)',
112+
'Please select your favorite colors (defaults to red and blue)',
113113
array('red', 'blue', 'yellow'),
114-
'red'
114+
'0,1'
115115
);
116116
$question->setMultiselect(true);
117117

@@ -121,6 +121,9 @@ this use :method:`Symfony\\Component\\Console\\Question\\ChoiceQuestion::setMult
121121
Now, when the user enters ``1,2``, the result will be:
122122
``You have just selected: blue, yellow``.
123123

124+
If the user does not enter anything, the result will be:
125+
``You have just selected: red, blue``.
126+
124127
Autocompletion
125128
~~~~~~~~~~~~~~
126129

@@ -206,7 +209,7 @@ You can also use a validator with a hidden question::
206209
use Symfony\Component\Console\Question\Question;
207210
// ...
208211

209-
$helper = $this->getHelperSet()->get('question');
212+
$helper = $this->getHelper('question');
210213

211214
$question = new Question('Please enter your password');
212215
$question->setValidator(function ($value) {

components/console/helpers/tablehelper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ When building a console application it may be useful to display tabular data:
2121
To display a table, use the :class:`Symfony\\Component\\Console\\Helper\\TableHelper`,
2222
set headers, rows and render::
2323

24-
$table = $this->getHelperSet()->get('table');
24+
$table = $this->getHelper('table');
2525
$table
2626
->setHeaders(array('ISBN', 'Title', 'Author'))
2727
->setRows(array(

components/expression_language/extending.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ This method has 3 arguments:
3535
3636
$language = new ExpressionLanguage();
3737
$language->register('lowercase', function ($str) {
38-
if (!is_string($str)) {
39-
return $str;
40-
}
41-
42-
return sprintf('strtolower(%s)', $str);
38+
is_string(%1$s) ? strtolower(%1$s) : %1$s;
4339
}, function ($arguments, $str) {
4440
if (!is_string($str)) {
4541
return $str;

contributing/code/bc.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ your overridden method wouldn't match anymore and generate a fatal error.
138138
.. note::
139139

140140
As with interfaces, we limit ourselves to changes that can be upgraded
141-
easily. We will document the precise ugprade instructions in the UPGRADE
141+
easily. We will document the precise upgrade instructions in the UPGRADE
142142
file in Symfony's root directory.
143143

144144
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
307307
Remove type hint of an argument Yes Yes
308308
Change argument type Yes Yes
309309
Change return type Yes Yes
310+
**Static Methods**
311+
Turn non static into static No No
312+
Turn static into non static No No
310313
================================================== ============== ==============
311314

312315
.. [1] Your code may be broken by changes in the Symfony code. Such changes will

cookbook/cache/varnish.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ application:
3838
set req.http.Surrogate-Capability = "abc=ESI/1.0";
3939
}
4040
41+
.. note::
42+
43+
The ``abc`` part of the header isn't important unless you have multiple "surrogates"
44+
that need to advertise their capabilities. See `Surrogate-Capability Header`_ for details.
45+
4146
Then, optimize Varnish so that it only parses the Response contents when there
4247
is at least one ESI tag by checking the ``Surrogate-Control`` header that
4348
Symfony2 adds automatically:
@@ -217,3 +222,4 @@ absolute URLs:
217222
.. _`Varnish`: https://www.varnish-cache.org
218223
.. _`Edge Architecture`: http://www.w3.org/TR/edge-arch
219224
.. _`GZIP and Varnish`: https://www.varnish-cache.org/docs/3.0/phk/gzip.html
225+
.. _`Surrogate-Capability Header`: http://www.w3.org/TR/edge-arch

cookbook/form/form_customization.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,22 @@ When the ``form.age`` widget is rendered, Symfony will use the ``integer_widget`
298298
block from the new template and the ``input`` tag will be wrapped in the
299299
``div`` element specified in the customized block.
300300

301+
Multiple Templates
302+
..................
303+
304+
A form can also be customized by applying several templates. To do this, pass the
305+
name of all the templates as an array using the ``with`` keyword:
306+
307+
.. code-block:: html+jinja
308+
309+
{% form_theme form with ['::common.html.twig', ':Form:fields.html.twig',
310+
'AcmeDemoBundle:Form:fields.html.twig'] %}
311+
312+
{# ... #}
313+
314+
The templates can be located at different bundles and they can even be stored
315+
at the global ``app/Resources/views/`` directory.
316+
301317
Child Forms
302318
...........
303319

cookbook/testing/profiling.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,52 @@ finish. It's easy to achieve if you embed the token in the error message::
7373

7474
Read the API for built-in :doc:`data collectors </cookbook/profiler/data_collector>`
7575
to learn more about their interfaces.
76+
77+
Speeding up Tests by not Collecting Profiler Data
78+
-------------------------------------------------
79+
80+
To avoid collecting data in each test you can set the ``collect`` parameter
81+
to false:
82+
83+
.. configuration-block::
84+
85+
.. code-block:: yaml
86+
87+
# app/config/config_test.yml
88+
89+
# ...
90+
framework:
91+
profiler:
92+
enabled: true
93+
collect: false
94+
95+
.. code-block:: xml
96+
97+
<!-- app/config/config.xml -->
98+
<?xml version="1.0" encoding="UTF-8" ?>
99+
<container xmlns="http://symfony.com/schema/dic/services"
100+
xmlns:framework="http://symfony.com/schema/dic/symfony"
101+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
102+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
103+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
104+
105+
<!-- ... -->
106+
107+
<framework:config>
108+
<framework:profiler enabled="true" collect="false" />
109+
</framework:config>
110+
</container>
111+
112+
.. code-block:: php
113+
114+
// app/config/config.php
115+
116+
// ...
117+
$container->loadFromExtension('framework', array(
118+
'profiler' => array(
119+
'enabled' => true,
120+
'collect' => false,
121+
),
122+
));
123+
124+
In this way only tests that call ``$client->enableProfiler()`` will collect data.

0 commit comments

Comments
 (0)
0