Skip to content

Commit eff11ef

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [File Uploads] Check if the entity contains the files [HttpFoundation][Fix] Component version Explain how to get all flash messages Documented the security options related to redirections Reworded a note about custom constraints Minor fix in event (file uploading) Update configuration.rst Fixed a syntax issue Minor change Fix .rst formatting Twig Extension does no longer need getName() method Document that you can't pass empty strings to console options
2 parents f306a3c + 185e886 commit eff11ef

File tree

8 files changed

+83
-29
lines changed

8 files changed

+83
-29
lines changed

bundles/configuration.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ configuration of a specific bundle. The namespace is returned from the
325325
:method:`Extension::getNamespace() <Symfony\\Component\\DependencyInjection\\Extension\\Extension::getNamespace>`
326326
method. By convention, the namespace is a URL (it doesn't have to be a valid
327327
URL nor does it need to exists). By default, the namespace for a bundle is
328-
``http://example.org/dic/schema/DI_ALIAS``, where ``DI_ALIAS`` is the DI alias of
328+
``http://example.org/schema/dic/DI_ALIAS``, where ``DI_ALIAS`` is the DI alias of
329329
the extension. You might want to change this to a more professional URL::
330330

331331
// src/Acme/HelloBundle/DependencyInjection/AcmeHelloExtension.php

console/input.rst

+4
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,7 @@ You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or
206206
when the option was used without a value (``command --language``) or when
207207
it wasn't used at all (``command``). In both cases, the value retrieved for
208208
the option will be ``null``.
209+
210+
Similarly, due to a PHP limitation, there is no way to pass an empty string
211+
as the value of an option. In ``command --prefix`` and ``command --prefix=''``
212+
cases, the value of the ``prefix`` option will be ``null``.

controller.rst

+24-2
Original file line numberDiff line numberDiff line change
@@ -422,21 +422,43 @@ read any flash messages from the session:
422422
.. code-block:: html+twig
423423

424424
{# app/Resources/views/base.html.twig #}
425-
{% for flash_message in app.session.flashBag.get('notice') %}
425+
426+
{# you can read and display just one flash message type... #}
427+
{% for flash_message in app.session.flash('notice') %}
426428
<div class="flash-notice">
427429
{{ flash_message }}
428430
</div>
429431
{% endfor %}
430432

433+
{# ...or you can read and display every flash message available #}
434+
{% for type, flash_messages in app.session.flashes %}
435+
{% for flash_message in flash_messages %}
436+
<div class="flash-{{ type }}">
437+
{{ flash_message }}
438+
</div>
439+
{% endif %}
440+
{% endfor %}
441+
431442
.. code-block:: html+php
432443

433444
<!-- app/Resources/views/base.html.php -->
445+
446+
// you can read and display just one flash message type...
434447
<?php foreach ($view['session']->getFlash('notice') as $message): ?>
435448
<div class="flash-notice">
436-
<?php echo "<div class='flash-error'>$message</div>" ?>
449+
<?php echo $message ?>
437450
</div>
438451
<?php endforeach ?>
439452

453+
// ...or you can read and display every flash message available
454+
<?php foreach ($view['session']->getFlashes() as $type => $flash_messages): ?>
455+
<?php foreach ($flash_messages as $flash_message): ?>
456+
<div class="flash-<?php echo $type ?>">
457+
<?php echo $message ?>
458+
</div>
459+
<?php endforeach ?>
460+
<?php endforeach ?>
461+
440462
.. note::
441463

442464
It's common to use ``notice``, ``warning`` and ``error`` as the keys of the

controller/upload_file.rst

+11-2
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ logic to a separate service::
243243

244244
return $fileName;
245245
}
246+
247+
public function getTargetDir()
248+
{
249+
return $this->targetDir;
250+
}
246251
}
247252

248253
Then, define a service for this class:
@@ -443,9 +448,13 @@ controller.
443448
{
444449
$entity = $args->getEntity();
445450

446-
$fileName = $entity->getBrochure();
451+
if (!$entity instanceof Product) {
452+
return;
453+
}
447454

448-
$entity->setBrochure(new File($this->targetPath.'/'.$fileName));
455+
if ($fileName = $entity->getBrochure()) {
456+
$entity->setBrochure(new File($this->uploader->getTargetDir().'/'.$fileName));
457+
}
449458
}
450459
}
451460

create_framework/http_foundation.rst

+1-12
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,7 @@ To use this component, add it as a dependency of the project:
119119
Running this command will also automatically download the Symfony
120120
HttpFoundation component and install it under the ``vendor/`` directory.
121121
A ``composer.json`` and a ``composer.lock`` file will be generated as well,
122-
containing the new requirement:
123-
124-
.. code-block:: json
125-
126-
{
127-
"require": {
128-
"symfony/http-foundation": "^2.7"
129-
}
130-
}
131-
132-
The code block shows the content of the ``composer.json`` file (the actual
133-
version may vary).
122+
containing the new requirement.
134123

135124
.. sidebar:: Class Autoloading
136125

reference/configuration/security.rst

+31-4
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,37 @@ request to the ``check_path`` URL.
396396
Redirecting after Login
397397
~~~~~~~~~~~~~~~~~~~~~~~
398398

399-
* ``always_use_default_target_path`` (type: ``boolean``, default: ``false``)
400-
* ``default_target_path`` (type: ``string``, default: ``/``)
401-
* ``target_path_parameter`` (type: ``string``, default: ``_target_path``)
402-
* ``use_referer`` (type: ``boolean``, default: ``false``)
399+
always_use_default_target_path
400+
..............................
401+
402+
**type**: ``boolean`` **default**: ``false``
403+
404+
If ``true``, users are always redirected to the default target path regardless
405+
of the previous URL that was stored in the session.
406+
407+
default_target_path
408+
....................
409+
410+
**type**: ``string`` **default**: ``/``
411+
412+
The page users are redirected to when there is no previous page stored in the
413+
session (for example, when the users browse the login page directly).
414+
415+
target_path_parameter
416+
.....................
417+
418+
**type**: ``string`` **default**: ``_target_path``
419+
420+
When using a login form, if you include an HTML element to set the target path,
421+
this option lets you change the name of the HTML element itself.
422+
423+
use_referer
424+
...........
425+
426+
**type**: ``boolean`` **default**: ``false``
427+
428+
If ``true``, the user is redirected to the value stored in the ``HTTP_REFERER``
429+
header when no previous URL was stored in the session.
403430

404431
.. _reference-security-pbkdf2:
405432

templating/twig_extension.rst

+8-5
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ As an example you'll create a price filter to format a given number into price::
4949

5050
return $price;
5151
}
52-
53-
public function getName()
54-
{
55-
return 'app_extension';
56-
}
5752
}
5853

54+
.. note::
55+
56+
  Prior to Twig 1.26, your extension had to define an additional ``getName()``
57+
method that returned a string with the extension's internal name (e.g.
58+
``app.my_extension``). When your extension needs to be compatible with Twig
59+
versions before 1.26, include this method which is omitted in the example
60+
above.
61+
5962
.. tip::
6063

6164
Along with custom filters, you can also add custom `functions`_ and register

validation/custom_constraint.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ load this service from the container.
202202

203203
.. note::
204204

205-
In earlier versions of Symfony, the tag required an ``alias`` key (usually set
206-
to the class name). This is still allowed your constraint's ``validateBy()``
207-
method can return this alias (instead of a class name).
205+
In earlier versions of Symfony, the tag required an ``alias`` key (usually
206+
set to the class name). This ``alias`` is now optional, but if you define
207+
it, your constraint's ``validatedBy()`` method must return the same value.
208208

209209
Class Constraint Validator
210210
~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)