Skip to content

Commit fc10807

Browse files
committed
Merge branch '3.2'
* 3.2: [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 Fix faulty conflict resolution Fixed a syntax issue Minor change Fix .rst formatting Twig Extension does no longer need getName() method Fixed the RST syntax Minor rewords [DependencyInjection][Improve] Constant YAML with expression language] [Yaml] fix dump arguments Standalone TwigRendererEngine argument Document that you can't pass empty strings to console options
2 parents 266e14e + 2ac669f commit fc10807

File tree

12 files changed

+87
-34
lines changed

12 files changed

+87
-34
lines changed

bundles/configuration.rst

Lines changed: 1 addition & 1 deletion
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

components/form.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension
193193
$viewsDir,
194194
$vendorTwigBridgeDir.'/Resources/views/Form',
195195
)));
196-
$formEngine = new TwigRendererEngine(array($defaultFormTheme));
196+
$formEngine = new TwigRendererEngine(array($defaultFormTheme), $twig);
197197
$twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
198198
TwigRenderer::class => function () use ($formEngine, $csrfManager) {
199199
return new TwigRenderer($formEngine, $csrfManager);

components/yaml.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ flag::
276276
Similarly you can use ``DUMP_EXCEPTION_ON_INVALID_TYPE`` when dumping::
277277

278278
$data = new \stdClass(); // by default objects are invalid.
279-
Yaml::dump($data, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); // throws an exception
279+
Yaml::dump($data, 2, 4, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); // throws an exception
280280

281281
echo $yaml; // { foo: bar }
282282

console/input.rst

Lines changed: 4 additions & 0 deletions
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``.

contributing/code/core_team.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Active Core Members
6666
* **Christophe Coevoet** (`stof`_) can merge into all components, bridges and
6767
bundles;
6868

69-
* **Kévin Dunglas** (`dunglas`_) can merge into the Serializer_
69+
* **Kévin Dunglas** (`dunglas`_) can merge into the PropertyInfo_ and the Serializer_
7070
component;
7171

7272
* **Abdellatif AitBoudad** (`aitboudad`_) can merge into the Translation_

controller.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,21 +418,43 @@ read any flash messages from the session:
418418
.. code-block:: html+twig
419419

420420
{# app/Resources/views/base.html.twig #}
421-
{% for flash_message in app.session.flashBag.get('notice') %}
421+
422+
{# you can read and display just one flash message type... #}
423+
{% for flash_message in app.session.flash('notice') %}
422424
<div class="flash-notice">
423425
{{ flash_message }}
424426
</div>
425427
{% endfor %}
426428

429+
{# ...or you can read and display every flash message available #}
430+
{% for type, flash_messages in app.session.flashes %}
431+
{% for flash_message in flash_messages %}
432+
<div class="flash-{{ type }}">
433+
{{ flash_message }}
434+
</div>
435+
{% endif %}
436+
{% endfor %}
437+
427438
.. code-block:: html+php
428439

429440
<!-- app/Resources/views/base.html.php -->
441+
442+
// you can read and display just one flash message type...
430443
<?php foreach ($view['session']->getFlash('notice') as $message): ?>
431444
<div class="flash-notice">
432-
<?php echo "<div class='flash-error'>$message</div>" ?>
445+
<?php echo $message ?>
433446
</div>
434447
<?php endforeach ?>
435448

449+
// ...or you can read and display every flash message available
450+
<?php foreach ($view['session']->getFlashes() as $type => $flash_messages): ?>
451+
<?php foreach ($flash_messages as $flash_message): ?>
452+
<div class="flash-<?php echo $type ?>">
453+
<?php echo $message ?>
454+
</div>
455+
<?php endforeach ?>
456+
<?php endforeach ?>
457+
436458
.. note::
437459

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

controller/upload_file.rst

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

Lines changed: 1 addition & 12 deletions
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": "^3.0"
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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,37 @@ request to the ``check_path`` URL.
386386
Redirecting after Login
387387
~~~~~~~~~~~~~~~~~~~~~~~
388388

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

394421
.. _reference-security-pbkdf2:
395422

service_container/parameters.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ key and define the type as ``constant``.
230230
parameters:
231231
global.constant.value: !php/const:GLOBAL_CONSTANT
232232
my_class.constant.value: !php/const:My_Class::CONSTANT_NAME
233-
233+
234234
.. code-block:: xml
235235
236236
<?xml version="1.0" encoding="UTF-8" ?>
@@ -249,7 +249,6 @@ key and define the type as ``constant``.
249249
$container->setParameter('global.constant.value', GLOBAL_CONSTANT);
250250
$container->setParameter('my_class.constant.value', My_Class::CONSTANT_NAME);
251251
252-
253252
PHP Keywords in XML
254253
-------------------
255254

templating/twig_extension.rst

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ load this service from the container.
193193

194194
.. note::
195195

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

200200
Class Constraint Validator
201201
~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)