Skip to content

Commit 76b5a21

Browse files
committed
Merge remote-tracking branch 'upstream/2.7' into 2.7
2 parents fab3a39 + 861e72b commit 76b5a21

File tree

4 files changed

+176
-18
lines changed

4 files changed

+176
-18
lines changed

components/yaml/yaml_format.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,22 @@ Comments can be added in YAML by prefixing them with a hash mark (``#``):
300300
Comments are simply ignored by the YAML parser and do not need to be
301301
indented according to the current level of nesting in a collection.
302302

303+
Explicit Typing
304+
---------------
305+
306+
The YAML specification defines some tags to set the type of any data explicitly:
307+
308+
.. code-block:: yaml
309+
310+
data:
311+
# this value is parsed as a float number (it will be 3.0 instead of 3)
312+
price: !!float 3
313+
314+
# this value is parsed as binary data encoded in base64
315+
picture: !!binary |
316+
R0lGODlhDAAMAIQAAP//9/X
317+
17unp5WZmZgAAAOfn515eXv
318+
Pz7Y6OjuDg4J+fn5OTk6enp
319+
56enmleECcgggoBADs=
320+
303321
.. _YAML: http://yaml.org/

doctrine/event_listeners_subscribers.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,58 @@ interface and have an event method for each event it subscribes to::
214214

215215
For a full reference, see chapter `The Event System`_ in the Doctrine documentation.
216216

217+
Lazy loading for Event Listeners
218+
--------------------------------
219+
220+
One subtle difference between listeners and subscribers is that Symfony can load
221+
entity listeners lazily. This means that your listener class will only be fetched
222+
from the service container (and thus be instantiated) once the event it is linked
223+
to actually fires.
224+
225+
Lazy loading might give you a slight performance improvement when your listener
226+
runs for events that rarely fire. Also, it can help you when you run into
227+
*circular dependency issues* that may occur when your listener service in turn
228+
depends on the DBAL connection.
229+
230+
To mark a listener service as lazily loaded, just add the ``lazy`` attribute
231+
to the tag like so:
232+
233+
.. configuration-block::
234+
235+
.. code-block:: yaml
236+
237+
services:
238+
my.listener:
239+
class: AppBundle\EventListener\SearchIndexer
240+
tags:
241+
- { name: doctrine.event_listener, event: postPersist, lazy: true }
242+
243+
.. code-block:: xml
244+
245+
<?xml version="1.0" ?>
246+
<container xmlns="http://symfony.com/schema/dic/services"
247+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine">
248+
249+
<services>
250+
<service id="my.listener" class="AppBundle\EventListener\SearchIndexer">
251+
<tag name="doctrine.event_listener" event="postPersist" lazy="true" />
252+
</service>
253+
</services>
254+
</container>
255+
256+
.. code-block:: php
257+
258+
use AppBundle\EventListener\SearchIndexer;
259+
260+
$container
261+
->register('my.listener', SearchIndexer::class)
262+
->addTag('doctrine.event_listener', array('event' => 'postPersist', 'lazy' => 'true'))
263+
;
264+
265+
.. note::
266+
267+
  Marking an event listener as ``lazy`` has nothing to do with lazy service
268+
definitions which are described :doc:`in their own section </service_container/lazy_services>`
269+
217270
.. _`The Event System`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html
218271
.. _`the Doctrine Documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#entity-listeners

reference/configuration/twig.rst

Lines changed: 103 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ TwigBundle Configuration ("twig")
5353
paths:
5454
'%kernel.root_dir%/../vendor/acme/foo-bar/templates': foo_bar
5555
56+
# The following were added in Symfony 2.7.
57+
date:
58+
format: d.m.Y, H:i:s
59+
interval_format: '%%d days'
60+
timezone: Asia/Tokyo
61+
number_format:
62+
decimals: 2
63+
decimal_point: ','
64+
thousands_separator: '.'
65+
5666
.. code-block:: xml
5767
5868
<!-- app/config/config.xml -->
@@ -79,6 +89,9 @@ TwigBundle Configuration ("twig")
7989
8090
<twig:global key="foo" id="bar" type="service" />
8191
<twig:global key="pi">3.14</twig:global>
92+
93+
<twig:date format="d.m.Y, H:i:s" interval-format="%d days" timezone="Asia/Tokyo" />
94+
<twig:number-format decimals="2" decimal-point="," thousands-separator="." />
8295
8396
<twig:exception-controller>AcmeFooBundle:Exception:showException</twig:exception-controller>
8497
<twig:path namespace="foo_bar">%kernel.root_dir%/../vendor/acme/foo-bar/templates</twig:path>
@@ -92,23 +105,33 @@ TwigBundle Configuration ("twig")
92105
'form_themes' => array(
93106
'form_div_layout.html.twig', // Default
94107
'form.html.twig',
95-
),
96-
'globals' => array(
97-
'foo' => '@bar',
98-
'pi' => 3.14,
99-
),
100-
'auto_reload' => '%kernel.debug%',
101-
'autoescape' => 'name',
102-
'base_template_class' => 'Twig_Template',
103-
'cache' => '%kernel.cache_dir%/twig',
104-
'charset' => '%kernel.charset%',
105-
'debug' => '%kernel.debug%',
106-
'strict_variables' => false,
107-
'exception_controller' => 'AcmeFooBundle:Exception:showException',
108-
'optimizations' => true,
109-
'paths' => array(
110-
'%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar',
111-
),
108+
),
109+
'globals' => array(
110+
'foo' => '@bar',
111+
'pi' => 3.14,
112+
),
113+
'auto_reload' => '%kernel.debug%',
114+
'autoescape' => 'name',
115+
'base_template_class' => 'Twig_Template',
116+
'cache' => '%kernel.cache_dir%/twig',
117+
'charset' => '%kernel.charset%',
118+
'debug' => '%kernel.debug%',
119+
'strict_variables' => false,
120+
'exception_controller' => 'AcmeFooBundle:Exception:showException',
121+
'optimizations' => true,
122+
'paths' => array(
123+
'%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar',
124+
),
125+
'date' => array(
126+
'format' => 'd.m.Y, H:i:s',
127+
'interval_format' => '%%d days',
128+
'timezone' => 'Asia/Tokyo',
129+
),
130+
'number_format' => array(
131+
'decimals' => 2,
132+
'decimal_point' => ',',
133+
'thousands_separator' => '.',
134+
),
112135
));
113136
114137
.. caution::
@@ -208,6 +231,37 @@ charset
208231
The charset used by the template files. In the Symfony Standard edition this
209232
defaults to the ``UTF-8`` charset.
210233

234+
date
235+
~~~~
236+
237+
These options define the default values used by the ``date`` filter to format
238+
date and time values. They are useful to avoid passing the same arguments on
239+
every ``date`` filter call.
240+
241+
format
242+
......
243+
244+
**type**: ``string`` **default**: ``F j, Y H:i``
245+
246+
The format used by the ``date`` filter to display values when no specific format
247+
is passed as argument.
248+
249+
internal_format
250+
...............
251+
252+
**type**: ``string`` **default**: ``%d days``
253+
254+
The format used by the ``date`` filter to display ``DateInterval`` instances
255+
when no specific format is passed as argument.
256+
257+
timezone
258+
........
259+
260+
**type**: ``string`` **default**: (the value returned by ``date_default_timezone_get()``)
261+
262+
The timezone used when formatting date values with the ``date`` filter and no
263+
specific timezone is passed as argument.
264+
211265
debug
212266
~~~~~
213267

@@ -232,6 +286,38 @@ option is advanced. If you need to customize an error page you should use
232286
the previous link. If you need to perform some behavior on an exception,
233287
you should add a listener to the ``kernel.exception`` event (see :ref:`dic-tags-kernel-event-listener`).
234288

289+
number_format
290+
~~~~~~~~~~~~~
291+
292+
These options define the default values used by the ``number_format`` filter to
293+
format numeric values. They are useful to avoid passing the same arguments on
294+
every ``number_format`` filter call.
295+
296+
decimals
297+
........
298+
299+
**type**: ``integer`` **default**: ``0``
300+
301+
The number of decimals used to format numeric values when no specific number is
302+
passed as argument to the ``number_format`` filter.
303+
304+
decimal_point
305+
.............
306+
307+
**type**: ``string`` **default**: ``.``
308+
309+
The character used to separate the decimals from the integer part of numeric
310+
values when no specific character is passed as argument to the ``number_format``
311+
filter.
312+
313+
thousands_separator
314+
...................
315+
316+
**type**: ``string`` **default**: ``,``
317+
318+
The character used to separate every group of thousands in numeric values when
319+
no specific character is passed as argument to the ``number_format`` filter.
320+
235321
optimizations
236322
~~~~~~~~~~~~~
237323

reference/forms/types/language.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ in the `International Components for Unicode`_ (e.g. ``fr`` or ``zh_Hant``).
1313

1414
.. note::
1515

16-
The locale of your user is guessed using :phpmethod:`Locale::getDefault`
16+
The locale of your user is guessed using :phpmethod:`Locale::getDefault`,
17+
which requires the ``intl`` PHP extension to be installed and enabled.
1718

1819
Unlike the ``choice`` type, you don't need to specify a ``choices`` or
1920
``choice_list`` option as the field type automatically uses a large list

0 commit comments

Comments
 (0)