Skip to content

Commit 9eb4b11

Browse files
committed
Merge branch '2.3' into 2.7
2 parents 206a98d + c39a43c commit 9eb4b11

File tree

10 files changed

+98
-162
lines changed

10 files changed

+98
-162
lines changed

book/http_cache.rst

Lines changed: 2 additions & 0 deletions
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();

components/config/definition.rst

Lines changed: 41 additions & 0 deletions
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

components/form/introduction.rst

Lines changed: 3 additions & 3 deletions
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

components/security/secure_tools.rst

Lines changed: 0 additions & 5 deletions
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

contributing/community/reviews.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ Pick a pull request from the `PRs in need of review`_ and follow these steps:
173173
$ git fetch origin pull/15723/head:pr15723
174174
$ git checkout pr15723
175175
176-
Now you can test the project against the code in the PR.
176+
Now you can :doc:`test the project </contributing/code/tests>` against
177+
the code in the PR.
177178

178179
#. **Update the PR Status**
179180

cookbook/controller/upload_file.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Finally, you need to update the code of the controller that handles the form::
122122
if ($form->isValid()) {
123123
// $file stores the uploaded PDF file
124124
/** @var Symfony\Component\HttpFoundation\File\UploadedFile $file */
125-
$file = $product->getBrochure()
125+
$file = $product->getBrochure();
126126

127127
// Generate a unique name for the file before saving it
128128
$fileName = md5(uniqid()).'.'.$file->guessExtension();
@@ -135,13 +135,13 @@ Finally, you need to update the code of the controller that handles the form::
135135
// instead of its contents
136136
$product->setBrochure($filename);
137137

138-
// persist the $product variable or any other work...
138+
// ... persist the $product variable or any other work
139139

140140
return $this->redirect($this->generateUrl('app_product_list'));
141141
}
142142

143143
return $this->render('product/new.html.twig', array(
144-
'form' => $form->createView()
144+
'form' => $form->createView(),
145145
));
146146
}
147147
}
@@ -150,10 +150,10 @@ There are some important things to consider in the code of the above controller:
150150

151151
#. When the form is uploaded, the ``brochure`` property contains the whole PDF
152152
file contents. Since this property stores just the file name, you must set
153-
its new value before persisting the changes of the entity.
153+
its new value before persisting the changes of the entity;
154154
#. In Symfony applications, uploaded files are objects of the
155155
:class:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile` class, which
156-
provides methods for the most common operations when dealing with uploaded files.
156+
provides methods for the most common operations when dealing with uploaded files;
157157
#. A well-known security best practice is to never trust the input provided by
158158
users. This also applies to the files uploaded by your visitors. The ``Uploaded``
159159
class provides methods to get the original file extension
@@ -163,7 +163,7 @@ There are some important things to consider in the code of the above controller:
163163
However, they are considered *not safe* because a malicious user could tamper
164164
that information. That's why it's always better to generate a unique name and
165165
use the :method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::guessExtension`
166-
method to let Symfony guess the right extension according to the file MIME type.
166+
method to let Symfony guess the right extension according to the file MIME type;
167167
#. The ``UploadedFile`` class also provides a :method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::move`
168168
method to store the file in its intended directory. Defining this directory
169169
path as an application configuration option is considered a good practice that

cookbook/form/data_transformers.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,17 @@ to and from the issue number and the ``Issue`` object::
161161
namespace AppBundle\Form\DataTransformer;
162162

163163
use AppBundle\Entity\Issue;
164-
use Doctrine\Common\Persistence\EntityManager;
164+
use Doctrine\Common\Persistence\ObjectManager;
165165
use Symfony\Component\Form\DataTransformerInterface;
166166
use Symfony\Component\Form\Exception\TransformationFailedException;
167167

168168
class IssueToNumberTransformer implements DataTransformerInterface
169169
{
170-
private $entityManager;
170+
private $manager;
171171

172-
public function __construct(EntityManager $entityManager)
172+
public function __construct(ObjectManager $manager)
173173
{
174-
$this->entityManager = $entityManager;
174+
$this->manager = $manager;
175175
}
176176

177177
/**
@@ -203,7 +203,7 @@ to and from the issue number and the ``Issue`` object::
203203
return;
204204
}
205205

206-
$issue = $this->entityManager
206+
$issue = $this->manager
207207
->getRepository('AppBundle:Issue')
208208
// query for the issue with this id
209209
->find($issueNumber)
@@ -253,16 +253,16 @@ to be passed in. Then, you can easily create and add the transformer::
253253
namespace AppBundle\Form\Type;
254254

255255
use AppBundle\Form\DataTransformer\IssueToNumberTransformer;
256-
use Doctrine\Common\Persistence\EntityManager;
256+
use Doctrine\Common\Persistence\ObjectManager;
257257

258258
// ...
259259
class TaskType extends AbstractType
260260
{
261-
private $entityManager;
261+
private $manager;
262262

263-
public function __construct(EntityManager $entityManager)
263+
public function __construct(ObjectManager $manager)
264264
{
265-
$this->entityManager = $entityManager;
265+
$this->manager = $manager;
266266
}
267267

268268
public function buildForm(FormBuilderInterface $builder, array $options)
@@ -277,7 +277,7 @@ to be passed in. Then, you can easily create and add the transformer::
277277
// ...
278278

279279
$builder->get('issue')
280-
->addModelTransformer(new IssueToNumberTransformer($this->entityManager));
280+
->addModelTransformer(new IssueToNumberTransformer($this->manager));
281281
}
282282

283283
// ...
@@ -286,8 +286,8 @@ to be passed in. Then, you can easily create and add the transformer::
286286
Now, when you create your ``TaskType``, you'll need to pass in the entity manager::
287287

288288
// e.g. in a controller somewhere
289-
$entityManager = $this->getDoctrine()->getManager();
290-
$form = $this->createForm(new TaskType($entityManager), $task);
289+
$manager = $this->getDoctrine()->getManager();
290+
$form = $this->createForm(new TaskType($manager), $task);
291291

292292
// ...
293293

@@ -331,23 +331,23 @@ First, create the custom field type class::
331331
namespace AppBundle\Form;
332332

333333
use AppBundle\Form\DataTransformer\IssueToNumberTransformer;
334-
use Doctrine\ORM\EntityManager;
334+
use Doctrine\Common\Persistence\ObjectManager;
335335
use Symfony\Component\Form\AbstractType;
336336
use Symfony\Component\Form\FormBuilderInterface;
337337
use Symfony\Component\OptionsResolver\OptionsResolver;
338338

339339
class IssueSelectorType extends AbstractType
340340
{
341-
private $entityManager;
341+
private $manager;
342342

343-
public function __construct(EntityManager $entityManager)
343+
public function __construct(ObjectManager $manager)
344344
{
345-
$this->entityManager = $entityManager;
345+
$this->manager = $manager;
346346
}
347347

348348
public function buildForm(FormBuilderInterface $builder, array $options)
349349
{
350-
$transformer = new IssueToNumberTransformer($this->entityManager);
350+
$transformer = new IssueToNumberTransformer($this->manager);
351351
$builder->addModelTransformer($transformer);
352352
}
353353

cookbook/logging/monolog.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ using a processor.
342342
monolog.formatter.session_request:
343343
class: Monolog\Formatter\LineFormatter
344344
arguments:
345-
- "[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%%\n"
345+
- "[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n"
346346
347347
monolog.processor.session_request:
348348
class: Acme\MyBundle\SessionRequestProcessor
@@ -374,7 +374,7 @@ using a processor.
374374
<service id="monolog.formatter.session_request"
375375
class="Monolog\Formatter\LineFormatter">
376376
377-
<argument>[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%%&#xA;</argument>
377+
<argument>[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%&#xA;</argument>
378378
</service>
379379
380380
<service id="monolog.processor.session_request"
@@ -404,7 +404,7 @@ using a processor.
404404
'monolog.formatter.session_request',
405405
'Monolog\Formatter\LineFormatter'
406406
)
407-
->addArgument('[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%%\n');
407+
->addArgument('[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n');
408408
409409
$container
410410
->register(

0 commit comments

Comments
 (0)