Skip to content

Commit 838ba1d

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [symfony#8211] minor reword Reword Update language.rst Mention lazy loading for Doctrine event listeners Documented the WebProfilerBundle configuration Typo fixed in a doctrine docs [symfony#8245] link text directly Link to '"creating a reproducer" in "reporting a bug" Removed an extra line Updated xml config Fixed entity manager service name Added docs for "date" and "number_format" Twig options
2 parents 7452bad + c2b2c17 commit 838ba1d

File tree

8 files changed

+236
-40
lines changed

8 files changed

+236
-40
lines changed

contributing/code/bugs.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ If your problem definitely looks like a bug, report it using the official bug
2626
* Describe the steps needed to reproduce the bug with short code examples
2727
(providing a unit test that illustrates the bug is best);
2828

29-
* If the bug you experienced affects more than one layer, providing a simple
30-
failing unit test may not be sufficient. In this case, please fork the
31-
`Symfony Standard Edition`_ and reproduce your issue on a new branch;
29+
* If the bug you experienced is not obvious or affects more than one layer,
30+
providing a simple failing unit test may not be sufficient. In this case,
31+
please :doc:`provide a reproducer </contributing/code/reproducer>`;
3232

3333
* Give as much detail as possible about your environment (OS, PHP version,
3434
Symfony version, enabled extensions, ...);

doctrine.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ Updating an Object
632632
Once you've fetched an object from Doctrine, updating it is easy. Suppose
633633
you have a route that maps a product id to an update action in a controller::
634634

635-
use AppBundle\Entity\Post;
635+
use AppBundle\Entity\Product;
636636
// ...
637637

638638
public function updateAction($productId)

doctrine/event_listeners_subscribers.rst

+53
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

+103-17
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ TwigBundle Configuration ("twig")
5656
paths:
5757
'%kernel.root_dir%/../vendor/acme/foo-bar/templates': foo_bar
5858
59+
# The following were added in Symfony 2.7.
60+
date:
61+
format: d.m.Y, H:i:s
62+
interval_format: '%%d days'
63+
timezone: Asia/Tokyo
64+
number_format:
65+
decimals: 2
66+
decimal_point: ','
67+
thousands_separator: '.'
68+
5969
.. code-block:: xml
6070
6171
<!-- app/config/config.xml -->
@@ -82,6 +92,9 @@ TwigBundle Configuration ("twig")
8292
8393
<twig:global key="foo" id="bar" type="service" />
8494
<twig:global key="pi">3.14</twig:global>
95+
96+
<twig:date format="d.m.Y, H:i:s" interval-format="%d days" timezone="Asia/Tokyo" />
97+
<twig:number-format decimals="2" decimal-point="," thousands-separator="." />
8598
8699
<twig:exception-controller>AcmeFooBundle:Exception:showException</twig:exception-controller>
87100
<twig:path namespace="foo_bar">%kernel.root_dir%/../vendor/acme/foo-bar/templates</twig:path>
@@ -95,23 +108,33 @@ TwigBundle Configuration ("twig")
95108
'form_themes' => array(
96109
'form_div_layout.html.twig', // Default
97110
'form.html.twig',
98-
),
99-
'globals' => array(
100-
'foo' => '@bar',
101-
'pi' => 3.14,
102-
),
103-
'auto_reload' => '%kernel.debug%',
104-
'autoescape' => 'name',
105-
'base_template_class' => 'Twig_Template',
106-
'cache' => '%kernel.cache_dir%/twig',
107-
'charset' => '%kernel.charset%',
108-
'debug' => '%kernel.debug%',
109-
'strict_variables' => false,
110-
'exception_controller' => 'AcmeFooBundle:Exception:showException',
111-
'optimizations' => true,
112-
'paths' => array(
113-
'%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar',
114-
),
111+
),
112+
'globals' => array(
113+
'foo' => '@bar',
114+
'pi' => 3.14,
115+
),
116+
'auto_reload' => '%kernel.debug%',
117+
'autoescape' => 'name',
118+
'base_template_class' => 'Twig_Template',
119+
'cache' => '%kernel.cache_dir%/twig',
120+
'charset' => '%kernel.charset%',
121+
'debug' => '%kernel.debug%',
122+
'strict_variables' => false,
123+
'exception_controller' => 'AcmeFooBundle:Exception:showException',
124+
'optimizations' => true,
125+
'paths' => array(
126+
'%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar',
127+
),
128+
'date' => array(
129+
'format' => 'd.m.Y, H:i:s',
130+
'interval_format' => '%%d days',
131+
'timezone' => 'Asia/Tokyo',
132+
),
133+
'number_format' => array(
134+
'decimals' => 2,
135+
'decimal_point' => ',',
136+
'thousands_separator' => '.',
137+
),
115138
));
116139
117140
.. caution::
@@ -211,6 +234,37 @@ charset
211234
The charset used by the template files. In the Symfony Standard edition this
212235
defaults to the ``UTF-8`` charset.
213236

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

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

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

reference/configuration/web_profiler.rst

+69-13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,71 @@
44
WebProfilerBundle Configuration ("web_profiler")
55
================================================
66

7+
The WebProfilerBundle provides detailed technical information about each request
8+
execution and displays it in both the web debug toolbar and the profiler.
9+
10+
.. caution::
11+
12+
The web debug toolbar is not available for responses of type ``StreamedResponse``.
13+
14+
Configuration
15+
-------------
16+
17+
* `toolbar`_
18+
* `position`_
19+
* `intercept_redirects`_
20+
* `excluded_ajax_paths`_
21+
* `verbose`_
22+
23+
toolbar
24+
~~~~~~~
25+
26+
**type**: ``boolean`` **default**: ``true``
27+
28+
It enables and disables the toolbar entirely. Usually you set this to ``true``
29+
in the ``dev`` and ``test`` environments and to ``false`` in the ``prod``
30+
environment.
31+
32+
position
33+
~~~~~~~~
34+
35+
**type**: ``string`` **default**: ``bottom``
36+
37+
It defines the location of the browser window where the toolbar is displayed.
38+
the only allowed values are ``bottom`` and ``top``.
39+
40+
intercept_redirects
41+
~~~~~~~~~~~~~~~~~~~
42+
43+
**type**: ``boolean`` **default**: ``false``
44+
45+
If a redirect occurs during an HTTP response, the browser follows it automatically
46+
and you won't see the toolbar or the profiler of the original URL, only the
47+
redirected URL.
48+
49+
When setting this option to ``true``, the browser *stops* before making any
50+
redirection and shows you the URL which is going to redirect to, its toolbar,
51+
and its profiler. Once you've inspected the toolbar/profiler data, you can click
52+
on the given link to perform the redirect.
53+
54+
excluded_ajax_paths
55+
~~~~~~~~~~~~~~~~~~~
56+
57+
**type**: ``string`` **default**: ``'^/(app(_[\\w]+)?\\.php/)?_wdt'``
58+
59+
When the toolbar logs Ajax requests, it matches their URLs against this regular
60+
expression. If the URL matches, the request is not displayed in the toolbar. This
61+
is useful when the application makes lots of Ajax requests or they are heavy and
62+
you want to exclude some of them.
63+
64+
verbose
65+
~~~~~~~
66+
67+
**type**: ``boolean`` **default**: ``true``
68+
69+
This option is **deprecated** and has no effect on the toolbar or the profiler,
70+
so you can safely remove it from your configuration.
71+
772
Full Default Configuration
873
--------------------------
974

@@ -13,23 +78,14 @@ Full Default Configuration
1378
1479
# app/config/config.yml
1580
web_profiler:
16-
17-
# DEPRECATED, it is not useful anymore and can be removed
18-
# safely from your configuration
19-
verbose: true
20-
21-
# display the web debug toolbar at the bottom of pages with
22-
# a summary of profiler info
2381
toolbar: false
2482
position: bottom
25-
26-
# gives you the opportunity to look at the collected data
27-
# before following the redirect
28-
intercept_redirects: false
29-
30-
# Exclude AJAX requests in the web debug toolbar for specified paths
83+
intercept_redirects: false
3184
excluded_ajax_paths: ^/bundles|^/_wdt
3285
86+
# DEPRECATED, it can be removed safely from your configuration
87+
verbose: true
88+
3389
.. code-block:: xml
3490
3591
<!-- app/config/config.xml -->

reference/forms/types/language.rst

+2-1
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 ``ChoiceType``, you don't need to specify a ``choices`` option as the
1920
field type automatically uses a large list of languages. You *can* specify the option

service_container.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ a very special object called the **service container**. If you have the service
1515
then you can fetch a service by using that service's id::
1616

1717
$logger = $container->get('logger');
18-
$entityManager = $container->get('doctrine.entity_manager');
18+
$entityManager = $container->get('doctrine.orm.entity_manager');
1919

2020
The container is the *heart* of Symfony: it allows you to standardize and centralize
2121
the way objects are constructed. It makes your life easier, is super fast, and emphasizes

service_container/parent_services.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ How to Manage Common Dependencies with Parent Services
77
As you add more functionality to your application, you may well start to
88
have related classes that share some of the same dependencies. For example,
99
you may have multiple repository classes which need the
10-
``doctrine.entity_manager`` service and an optional ``logger`` service::
10+
``doctrine.orm.entity_manager`` service and an optional ``logger`` service::
1111

1212
// src/AppBundle/Repository/BaseDoctrineRepository.php
1313
namespace AppBundle\Repository;
@@ -67,7 +67,7 @@ duplicated service definitions:
6767
app.base_doctrine_repository:
6868
# as no class is configured, the parent service MUST be abstract
6969
abstract: true
70-
arguments: ['@doctrine.entity_manager']
70+
arguments: ['@doctrine.orm.entity_manager']
7171
calls:
7272
- [setLogger, ['@logger']]
7373
@@ -93,7 +93,7 @@ duplicated service definitions:
9393
<services>
9494
<!-- as no class is configured, the parent service MUST be abstract -->
9595
<service id="app.base_doctrine_repository" abstract="true">
96-
<argument type="service" id="doctrine.entity_manager" />
96+
<argument type="service" id="doctrine.orm.entity_manager" />
9797
9898
<call method="setLogger">
9999
<argument type="service" id="logger" />
@@ -124,7 +124,7 @@ duplicated service definitions:
124124
125125
// as no class is configured, the parent service MUST be abstract
126126
$container->register('app.base_doctrine_repository')
127-
->addArgument(new Reference('doctrine.entity_manager'))
127+
->addArgument(new Reference('doctrine.orm.entity_manager'))
128128
->addMethodCall('setLogger', array(new Reference('logger')))
129129
;
130130

0 commit comments

Comments
 (0)