Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xabbuh committed Aug 1, 2017
2 parents 7452bad + c2b2c17 commit 838ba1d
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 40 deletions.
6 changes: 3 additions & 3 deletions contributing/code/bugs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ If your problem definitely looks like a bug, report it using the official bug
* Describe the steps needed to reproduce the bug with short code examples
(providing a unit test that illustrates the bug is best);

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

* Give as much detail as possible about your environment (OS, PHP version,
Symfony version, enabled extensions, ...);
Expand Down
2 changes: 1 addition & 1 deletion doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ Updating an Object
Once you've fetched an object from Doctrine, updating it is easy. Suppose
you have a route that maps a product id to an update action in a controller::

use AppBundle\Entity\Post;
use AppBundle\Entity\Product;
// ...

public function updateAction($productId)
Expand Down
53 changes: 53 additions & 0 deletions doctrine/event_listeners_subscribers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,58 @@ interface and have an event method for each event it subscribes to::

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

Lazy loading for Event Listeners
--------------------------------

One subtle difference between listeners and subscribers is that Symfony can load
entity listeners lazily. This means that your listener class will only be fetched
from the service container (and thus be instantiated) once the event it is linked
to actually fires.

Lazy loading might give you a slight performance improvement when your listener
runs for events that rarely fire. Also, it can help you when you run into
*circular dependency issues* that may occur when your listener service in turn
depends on the DBAL connection.

To mark a listener service as lazily loaded, just add the ``lazy`` attribute
to the tag like so:

.. configuration-block::

.. code-block:: yaml
services:
my.listener:
class: AppBundle\EventListener\SearchIndexer
tags:
- { name: doctrine.event_listener, event: postPersist, lazy: true }
.. code-block:: xml
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine">
<services>
<service id="my.listener" class="AppBundle\EventListener\SearchIndexer">
<tag name="doctrine.event_listener" event="postPersist" lazy="true" />
</service>
</services>
</container>
.. code-block:: php
use AppBundle\EventListener\SearchIndexer;
$container
->register('my.listener', SearchIndexer::class)
->addTag('doctrine.event_listener', array('event' => 'postPersist', 'lazy' => 'true'))
;
.. note::

  Marking an event listener as ``lazy`` has nothing to do with lazy service
definitions which are described :doc:`in their own section </service_container/lazy_services>`

.. _`The Event System`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html
.. _`the Doctrine Documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#entity-listeners
120 changes: 103 additions & 17 deletions reference/configuration/twig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ TwigBundle Configuration ("twig")
paths:
'%kernel.root_dir%/../vendor/acme/foo-bar/templates': foo_bar
# The following were added in Symfony 2.7.
date:
format: d.m.Y, H:i:s
interval_format: '%%d days'
timezone: Asia/Tokyo
number_format:
decimals: 2
decimal_point: ','
thousands_separator: '.'
.. code-block:: xml
<!-- app/config/config.xml -->
Expand All @@ -82,6 +92,9 @@ TwigBundle Configuration ("twig")
<twig:global key="foo" id="bar" type="service" />
<twig:global key="pi">3.14</twig:global>
<twig:date format="d.m.Y, H:i:s" interval-format="%d days" timezone="Asia/Tokyo" />
<twig:number-format decimals="2" decimal-point="," thousands-separator="." />
<twig:exception-controller>AcmeFooBundle:Exception:showException</twig:exception-controller>
<twig:path namespace="foo_bar">%kernel.root_dir%/../vendor/acme/foo-bar/templates</twig:path>
Expand All @@ -95,23 +108,33 @@ TwigBundle Configuration ("twig")
'form_themes' => array(
'form_div_layout.html.twig', // Default
'form.html.twig',
),
'globals' => array(
'foo' => '@bar',
'pi' => 3.14,
),
'auto_reload' => '%kernel.debug%',
'autoescape' => 'name',
'base_template_class' => 'Twig_Template',
'cache' => '%kernel.cache_dir%/twig',
'charset' => '%kernel.charset%',
'debug' => '%kernel.debug%',
'strict_variables' => false,
'exception_controller' => 'AcmeFooBundle:Exception:showException',
'optimizations' => true,
'paths' => array(
'%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar',
),
),
'globals' => array(
'foo' => '@bar',
'pi' => 3.14,
),
'auto_reload' => '%kernel.debug%',
'autoescape' => 'name',
'base_template_class' => 'Twig_Template',
'cache' => '%kernel.cache_dir%/twig',
'charset' => '%kernel.charset%',
'debug' => '%kernel.debug%',
'strict_variables' => false,
'exception_controller' => 'AcmeFooBundle:Exception:showException',
'optimizations' => true,
'paths' => array(
'%kernel.root_dir%/../vendor/acme/foo-bar/templates' => 'foo_bar',
),
'date' => array(
'format' => 'd.m.Y, H:i:s',
'interval_format' => '%%d days',
'timezone' => 'Asia/Tokyo',
),
'number_format' => array(
'decimals' => 2,
'decimal_point' => ',',
'thousands_separator' => '.',
),
));
.. caution::
Expand Down Expand Up @@ -211,6 +234,37 @@ charset
The charset used by the template files. In the Symfony Standard edition this
defaults to the ``UTF-8`` charset.

date
~~~~

These options define the default values used by the ``date`` filter to format
date and time values. They are useful to avoid passing the same arguments on
every ``date`` filter call.

format
......

**type**: ``string`` **default**: ``F j, Y H:i``

The format used by the ``date`` filter to display values when no specific format
is passed as argument.

internal_format
...............

**type**: ``string`` **default**: ``%d days``

The format used by the ``date`` filter to display ``DateInterval`` instances
when no specific format is passed as argument.

timezone
........

**type**: ``string`` **default**: (the value returned by ``date_default_timezone_get()``)

The timezone used when formatting date values with the ``date`` filter and no
specific timezone is passed as argument.

debug
~~~~~

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

number_format
~~~~~~~~~~~~~

These options define the default values used by the ``number_format`` filter to
format numeric values. They are useful to avoid passing the same arguments on
every ``number_format`` filter call.

decimals
........

**type**: ``integer`` **default**: ``0``

The number of decimals used to format numeric values when no specific number is
passed as argument to the ``number_format`` filter.

decimal_point
.............

**type**: ``string`` **default**: ``.``

The character used to separate the decimals from the integer part of numeric
values when no specific character is passed as argument to the ``number_format``
filter.

thousands_separator
...................

**type**: ``string`` **default**: ``,``

The character used to separate every group of thousands in numeric values when
no specific character is passed as argument to the ``number_format`` filter.

optimizations
~~~~~~~~~~~~~

Expand Down
82 changes: 69 additions & 13 deletions reference/configuration/web_profiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,71 @@
WebProfilerBundle Configuration ("web_profiler")
================================================

The WebProfilerBundle provides detailed technical information about each request
execution and displays it in both the web debug toolbar and the profiler.

.. caution::

The web debug toolbar is not available for responses of type ``StreamedResponse``.

Configuration
-------------

* `toolbar`_
* `position`_
* `intercept_redirects`_
* `excluded_ajax_paths`_
* `verbose`_

toolbar
~~~~~~~

**type**: ``boolean`` **default**: ``true``

It enables and disables the toolbar entirely. Usually you set this to ``true``
in the ``dev`` and ``test`` environments and to ``false`` in the ``prod``
environment.

position
~~~~~~~~

**type**: ``string`` **default**: ``bottom``

It defines the location of the browser window where the toolbar is displayed.
the only allowed values are ``bottom`` and ``top``.

intercept_redirects
~~~~~~~~~~~~~~~~~~~

**type**: ``boolean`` **default**: ``false``

If a redirect occurs during an HTTP response, the browser follows it automatically
and you won't see the toolbar or the profiler of the original URL, only the
redirected URL.

When setting this option to ``true``, the browser *stops* before making any
redirection and shows you the URL which is going to redirect to, its toolbar,
and its profiler. Once you've inspected the toolbar/profiler data, you can click
on the given link to perform the redirect.

excluded_ajax_paths
~~~~~~~~~~~~~~~~~~~

**type**: ``string`` **default**: ``'^/(app(_[\\w]+)?\\.php/)?_wdt'``

When the toolbar logs Ajax requests, it matches their URLs against this regular
expression. If the URL matches, the request is not displayed in the toolbar. This
is useful when the application makes lots of Ajax requests or they are heavy and
you want to exclude some of them.

verbose
~~~~~~~

**type**: ``boolean`` **default**: ``true``

This option is **deprecated** and has no effect on the toolbar or the profiler,
so you can safely remove it from your configuration.

Full Default Configuration
--------------------------

Expand All @@ -13,23 +78,14 @@ Full Default Configuration
# app/config/config.yml
web_profiler:
# DEPRECATED, it is not useful anymore and can be removed
# safely from your configuration
verbose: true
# display the web debug toolbar at the bottom of pages with
# a summary of profiler info
toolbar: false
position: bottom
# gives you the opportunity to look at the collected data
# before following the redirect
intercept_redirects: false
# Exclude AJAX requests in the web debug toolbar for specified paths
intercept_redirects: false
excluded_ajax_paths: ^/bundles|^/_wdt
# DEPRECATED, it can be removed safely from your configuration
verbose: true
.. code-block:: xml
<!-- app/config/config.xml -->
Expand Down
3 changes: 2 additions & 1 deletion reference/forms/types/language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ in the `International Components for Unicode`_ (e.g. ``fr`` or ``zh_Hant``).

.. note::

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

Unlike the ``ChoiceType``, you don't need to specify a ``choices`` option as the
field type automatically uses a large list of languages. You *can* specify the option
Expand Down
2 changes: 1 addition & 1 deletion service_container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ a very special object called the **service container**. If you have the service
then you can fetch a service by using that service's id::

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

The container is the *heart* of Symfony: it allows you to standardize and centralize
the way objects are constructed. It makes your life easier, is super fast, and emphasizes
Expand Down
8 changes: 4 additions & 4 deletions service_container/parent_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ How to Manage Common Dependencies with Parent Services
As you add more functionality to your application, you may well start to
have related classes that share some of the same dependencies. For example,
you may have multiple repository classes which need the
``doctrine.entity_manager`` service and an optional ``logger`` service::
``doctrine.orm.entity_manager`` service and an optional ``logger`` service::

// src/AppBundle/Repository/BaseDoctrineRepository.php
namespace AppBundle\Repository;
Expand Down Expand Up @@ -67,7 +67,7 @@ duplicated service definitions:
app.base_doctrine_repository:
# as no class is configured, the parent service MUST be abstract
abstract: true
arguments: ['@doctrine.entity_manager']
arguments: ['@doctrine.orm.entity_manager']
calls:
- [setLogger, ['@logger']]
Expand All @@ -93,7 +93,7 @@ duplicated service definitions:
<services>
<!-- as no class is configured, the parent service MUST be abstract -->
<service id="app.base_doctrine_repository" abstract="true">
<argument type="service" id="doctrine.entity_manager" />
<argument type="service" id="doctrine.orm.entity_manager" />
<call method="setLogger">
<argument type="service" id="logger" />
Expand Down Expand Up @@ -124,7 +124,7 @@ duplicated service definitions:
// as no class is configured, the parent service MUST be abstract
$container->register('app.base_doctrine_repository')
->addArgument(new Reference('doctrine.entity_manager'))
->addArgument(new Reference('doctrine.orm.entity_manager'))
->addMethodCall('setLogger', array(new Reference('logger')))
;
Expand Down

0 comments on commit 838ba1d

Please sign in to comment.