Skip to content

Commit b1ba29d

Browse files
committed
Merge branch '2.8'
2 parents bb2f991 + de141d5 commit b1ba29d

25 files changed

+411
-420
lines changed

Diff for: book/http_cache.rst

+2
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ header value::
651651
namespace AppBundle\Controller;
652652

653653
// ...
654+
use Symfony\Component\HttpFoundation\Response;
654655
use Symfony\Component\HttpFoundation\Request;
655656
use AppBundle\Entity\Article;
656657

@@ -665,6 +666,7 @@ header value::
665666

666667
$date = $authorDate > $articleDate ? $authorDate : $articleDate;
667668

669+
$response = new Response();
668670
$response->setLastModified($date);
669671
// Set response as public. Otherwise it will be private by default.
670672
$response->setPublic();

Diff for: components/config/definition.rst

+41
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,47 @@ tree with ``append()``::
404404
This is also useful to help you avoid repeating yourself if you have sections
405405
of the config that are repeated in different places.
406406

407+
The example results in the following:
408+
409+
.. configuration-block::
410+
411+
.. code-block:: yaml
412+
413+
database:
414+
connection:
415+
driver: ~ # Required
416+
host: localhost
417+
username: ~
418+
password: ~
419+
memory: false
420+
parameters: # Required
421+
422+
# Prototype
423+
name:
424+
value: ~ # Required
425+
426+
.. code-block:: xml
427+
428+
<database>
429+
<!-- driver: Required -->
430+
<connection
431+
driver=""
432+
host="localhost"
433+
username=""
434+
password=""
435+
memory="false"
436+
>
437+
438+
<!-- prototype -->
439+
<!-- value: Required -->
440+
<parameters
441+
name="parameters name"
442+
value=""
443+
/>
444+
445+
</connection>
446+
</database>
447+
407448
.. _component-config-normalization:
408449

409450
Normalization

Diff for: components/console/helpers/progressbar.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@ you can also set the current progress by calling the
4848
Prior to version 2.6, the progress bar only works if your platform
4949
supports ANSI codes; on other platforms, no output is generated.
5050

51-
.. versionadded:: 2.6
51+
.. tip::
52+
5253
If your platform doesn't support ANSI codes, updates to the progress
5354
bar are added as new lines. To prevent the output from being flooded,
5455
adjust the
5556
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::setRedrawFrequency`
5657
accordingly. By default, when using a ``max``, the redraw frequency
5758
is set to *10%* of your ``max``.
5859

60+
.. versionadded:: 2.6
61+
The ``setRedrawFrequency()`` method was introduced in Symfony 2.6.
62+
5963
If you don't know the number of steps in advance, just omit the steps argument
6064
when creating the :class:`Symfony\\Component\\Console\\Helper\\ProgressBar`
6165
instance::

Diff for: components/console/helpers/questionhelper.rst

+104-67
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ helper set, which you can get by calling
1313

1414
The Question Helper has a single method
1515
:method:`Symfony\\Component\\Console\\Command\\Command::ask` that needs an
16-
:class:`Symfony\\Component\\Console\\Output\\InputInterface` instance as the
16+
:class:`Symfony\\Component\\Console\\Input\\InputInterface` instance as the
1717
first argument, an :class:`Symfony\\Component\\Console\\Output\\OutputInterface`
1818
instance as the second argument and a
1919
:class:`Symfony\\Component\\Console\\Question\\Question` as last argument.
@@ -24,14 +24,24 @@ Asking the User for Confirmation
2424
Suppose you want to confirm an action before actually executing it. Add
2525
the following to your command::
2626

27-
use Symfony\Component\Console\Question\ConfirmationQuestion;
2827
// ...
28+
use Symfony\Component\Console\Input\InputInterface;
29+
use Symfony\Component\Console\Output\OutputInterface;
30+
use Symfony\Component\Console\Question\ConfirmationQuestion;
2931

30-
$helper = $this->getHelper('question');
31-
$question = new ConfirmationQuestion('Continue with this action?', false);
32+
class YourCommand extends Command
33+
{
34+
// ...
35+
36+
public function execute(InputInterface $input, OutputInterface $output)
37+
{
38+
$helper = $this->getHelper('question');
39+
$question = new ConfirmationQuestion('Continue with this action?', false);
3240

33-
if (!$helper->ask($input, $output, $question)) {
34-
return;
41+
if (!$helper->ask($input, $output, $question)) {
42+
return;
43+
}
44+
}
3545
}
3646

3747
In this case, the user will be asked "Continue with this action?". If the user
@@ -66,11 +76,15 @@ You can also ask a question with more than a simple yes/no answer. For instance,
6676
if you want to know a bundle name, you can add this to your command::
6777

6878
use Symfony\Component\Console\Question\Question;
69-
// ...
7079

71-
$question = new Question('Please enter the name of the bundle', 'AcmeDemoBundle');
80+
// ...
81+
public function execute(InputInterface $input, OutputInterface $output)
82+
{
83+
// ...
84+
$question = new Question('Please enter the name of the bundle', 'AcmeDemoBundle');
7285

73-
$bundle = $helper->ask($input, $output, $question);
86+
$bundle = $helper->ask($input, $output, $question);
87+
}
7488

7589
The user will be asked "Please enter the name of the bundle". They can type
7690
some name which will be returned by the
@@ -86,20 +100,24 @@ which makes sure that the user can only enter a valid string
86100
from a predefined list::
87101

88102
use Symfony\Component\Console\Question\ChoiceQuestion;
89-
// ...
90103

91-
$helper = $this->getHelper('question');
92-
$question = new ChoiceQuestion(
93-
'Please select your favorite color (defaults to red)',
94-
array('red', 'blue', 'yellow'),
95-
0
96-
);
97-
$question->setErrorMessage('Color %s is invalid.');
104+
// ...
105+
public function execute(InputInterface $input, OutputInterface $output)
106+
{
107+
// ...
108+
$helper = $this->getHelper('question');
109+
$question = new ChoiceQuestion(
110+
'Please select your favorite color (defaults to red)',
111+
array('red', 'blue', 'yellow'),
112+
0
113+
);
114+
$question->setErrorMessage('Color %s is invalid.');
98115

99-
$color = $helper->ask($input, $output, $question);
100-
$output->writeln('You have just selected: '.$color);
116+
$color = $helper->ask($input, $output, $question);
117+
$output->writeln('You have just selected: '.$color);
101118

102-
// ... do something with the color
119+
// ... do something with the color
120+
}
103121

104122
The option which should be selected by default is provided with the third
105123
argument of the constructor. The default is ``null``, which means that no
@@ -120,18 +138,22 @@ feature using comma separated values. This is disabled by default, to enable
120138
this use :method:`Symfony\\Component\\Console\\Question\\ChoiceQuestion::setMultiselect`::
121139

122140
use Symfony\Component\Console\Question\ChoiceQuestion;
123-
// ...
124141

125-
$helper = $this->getHelper('question');
126-
$question = new ChoiceQuestion(
127-
'Please select your favorite colors (defaults to red and blue)',
128-
array('red', 'blue', 'yellow'),
129-
'0,1'
130-
);
131-
$question->setMultiselect(true);
142+
// ...
143+
public function execute(InputInterface $input, OutputInterface $output)
144+
{
145+
// ...
146+
$helper = $this->getHelper('question');
147+
$question = new ChoiceQuestion(
148+
'Please select your favorite colors (defaults to red and blue)',
149+
array('red', 'blue', 'yellow'),
150+
'0,1'
151+
);
152+
$question->setMultiselect(true);
132153

133-
$colors = $helper->ask($input, $output, $question);
134-
$output->writeln('You have just selected: ' . implode(', ', $colors));
154+
$colors = $helper->ask($input, $output, $question);
155+
$output->writeln('You have just selected: ' . implode(', ', $colors));
156+
}
135157

136158
Now, when the user enters ``1,2``, the result will be:
137159
``You have just selected: blue, yellow``.
@@ -146,13 +168,17 @@ You can also specify an array of potential answers for a given question. These
146168
will be autocompleted as the user types::
147169

148170
use Symfony\Component\Console\Question\Question;
149-
// ...
150171

151-
$bundles = array('AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle');
152-
$question = new Question('Please enter the name of a bundle', 'FooBundle');
153-
$question->setAutocompleterValues($bundles);
172+
// ...
173+
public function execute(InputInterface $input, OutputInterface $output)
174+
{
175+
// ...
176+
$bundles = array('AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle');
177+
$question = new Question('Please enter the name of a bundle', 'FooBundle');
178+
$question->setAutocompleterValues($bundles);
154179

155-
$name = $helper->ask($input, $output, $question);
180+
$name = $helper->ask($input, $output, $question);
181+
}
156182

157183
Hiding the User's Response
158184
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -161,13 +187,17 @@ You can also ask a question and hide the response. This is particularly
161187
convenient for passwords::
162188

163189
use Symfony\Component\Console\Question\Question;
164-
// ...
165190

166-
$question = new Question('What is the database password?');
167-
$question->setHidden(true);
168-
$question->setHiddenFallback(false);
191+
// ...
192+
public function execute(InputInterface $input, OutputInterface $output)
193+
{
194+
// ...
195+
$question = new Question('What is the database password?');
196+
$question->setHidden(true);
197+
$question->setHiddenFallback(false);
169198

170-
$password = $helper->ask($input, $output, $question);
199+
$password = $helper->ask($input, $output, $question);
200+
}
171201

172202
.. caution::
173203

@@ -189,20 +219,24 @@ be suffixed with ``Bundle``. You can validate that by using the
189219
method::
190220

191221
use Symfony\Component\Console\Question\Question;
192-
// ...
193-
194-
$question = new Question('Please enter the name of the bundle', 'AcmeDemoBundle');
195-
$question->setValidator(function ($answer) {
196-
if ('Bundle' !== substr($answer, -6)) {
197-
throw new \RuntimeException(
198-
'The name of the bundle should be suffixed with \'Bundle\''
199-
);
200-
}
201-
return $answer;
202-
});
203-
$question->setMaxAttempts(2);
204222

205-
$name = $helper->ask($input, $output, $question);
223+
// ...
224+
public function execute(InputInterface $input, OutputInterface $output)
225+
{
226+
// ...
227+
$question = new Question('Please enter the name of the bundle', 'AcmeDemoBundle');
228+
$question->setValidator(function ($answer) {
229+
if ('Bundle' !== substr($answer, -6)) {
230+
throw new \RuntimeException(
231+
'The name of the bundle should be suffixed with \'Bundle\''
232+
);
233+
}
234+
return $answer;
235+
});
236+
$question->setMaxAttempts(2);
237+
238+
$name = $helper->ask($input, $output, $question);
239+
}
206240

207241
The ``$validator`` is a callback which handles the validation. It should
208242
throw an exception if there is something wrong. The exception message is displayed
@@ -222,23 +256,26 @@ Validating a Hidden Response
222256
You can also use a validator with a hidden question::
223257

224258
use Symfony\Component\Console\Question\Question;
225-
// ...
226-
227-
$helper = $this->getHelper('question');
228259

229-
$question = new Question('Please enter your password');
230-
$question->setValidator(function ($value) {
231-
if (trim($value) == '') {
232-
throw new \Exception('The password can not be empty');
233-
}
260+
// ...
261+
public function execute(InputInterface $input, OutputInterface $output)
262+
{
263+
// ...
264+
$helper = $this->getHelper('question');
234265

235-
return $value;
236-
});
237-
$question->setHidden(true);
238-
$question->setMaxAttempts(20);
266+
$question = new Question('Please enter your password');
267+
$question->setValidator(function ($value) {
268+
if (trim($value) == '') {
269+
throw new \Exception('The password can not be empty');
270+
}
239271

240-
$password = $helper->ask($input, $output, $question);
272+
return $value;
273+
});
274+
$question->setHidden(true);
275+
$question->setMaxAttempts(20);
241276

277+
$password = $helper->ask($input, $output, $question);
278+
}
242279

243280
Testing a Command that Expects Input
244281
------------------------------------
@@ -276,6 +313,6 @@ from the command line, you need to set the helper input stream::
276313
}
277314

278315
By setting the input stream of the ``QuestionHelper``, you imitate what the
279-
console would do internally with all user input through the cli. This way
316+
console would do internally with all user input through the CLI. This way
280317
you can test any user interaction (even complex ones) by passing an appropriate
281318
input stream.

Diff for: components/form/introduction.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension
189189
$defaultFormTheme = 'form_div_layout.html.twig';
190190

191191
$vendorDir = realpath(__DIR__.'/../vendor');
192-
// the path to TwigBridge so Twig can locate the
192+
// the path to TwigBridge library so Twig can locate the
193193
// form_div_layout.html.twig file
194-
$vendorTwigBridgeDir =
195-
$vendorDir.'/symfony/twig-bridge/Symfony/Bridge/Twig';
194+
$appVariableReflection = new \ReflectionClass('\Symfony\Bridge\Twig\AppVariable');
195+
$vendorTwigBridgeDir = dirname($appVariableReflection->getFileName());
196196
// the path to your other templates
197197
$viewsDir = realpath(__DIR__.'/../views');
198198

Diff for: components/security/secure_tools.rst

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ algorithm; you can use the same strategy in your own code thanks to the
2121
// is some known string (e.g. password) equal to some user input?
2222
$bool = StringUtils::equals($knownString, $userInput);
2323

24-
.. caution::
25-
26-
To avoid timing attacks, the known string must be the first argument
27-
and the user-entered string the second.
28-
2924
Generating a Secure random Number
3025
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3126

0 commit comments

Comments
 (0)