Skip to content

Commit

Permalink
Merge branch '3.4' into 4.0
Browse files Browse the repository at this point in the history
* 3.4:
  Improved the section about overriding bundle services
  Added a caution note about race conditions in EntityType
  Mention how to inject a specific Monolog service
  • Loading branch information
javiereguiluz committed Jul 13, 2018
2 parents 2057505 + 905c0a4 commit 6f3ef4d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 37 deletions.
31 changes: 6 additions & 25 deletions bundles/override.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,12 @@ before the bundle one).
Services & Configuration
------------------------

If you want to modify service definitions of another bundle, you can use a compiler
pass to change the class of the service or to modify method calls. In the following
example, the implementing class for the ``original-service-id`` is changed to
``App\YourService``:

.. code-block:: diff
// src/Kernel.php
namespace App;
// ...
+ use App\Service\YourService;
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
+ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
class Kernel extends BaseKernel implements CompilerPassInterface
{
+ public function process(ContainerBuilder $container)
+ {
+ $definition = $container->findDefinition('original-service-id');
+ $definition->setClass(YourService::class);
+ }
}
For more information on compiler passes, see :doc:`/service_container/compiler_passes`.
If you want to modify the services created by a bundle, you can use
:doc:`service decoration </service_container/service_decoration>`.

If you want to do more advanced manipulations, like removing services created by
other bundles, you must work with :doc:`service definitions </service_container/definitions>`
inside a :doc:`compiler pass </service_container/compiler_passes>`.

Entities & Entity Mapping
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion frontend/encore/simple-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,4 @@ If those entries include CSS/Sass files (e.g. ``homepage.js`` requires
Keep Going!
-----------

Go back to the :ref:`Encore Top List <encore-toc>` to learn more and add new features.
Go back to the :ref:`List of Encore Articles <encore-toc>` to learn more and add new features.
6 changes: 4 additions & 2 deletions logging/channels_handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,7 @@ You can also configure additional channels without the need to tag your services
),
));
With this, you can now send log messages to the ``foo`` channel by using
the automatically registered logger service ``monolog.logger.foo``.
Symfony automatically registers one service per channel (in this example, the
channel ``foo`` creates a service called ``monolog.logger.foo``). In order to
inject this service into others, you must update the service configuration to
:ref:`choose the specific service to inject <services-wire-specific-service>`.
9 changes: 9 additions & 0 deletions reference/constraints/UniqueEntity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ between all of the constraints in your user table:
}
}
.. caution::

This constraint doesn't provide any protection against `race conditions`_.
They may occur when another entity is persisted by an external process after
this validation has passed and before this entity is actually persisted in
the database.

Options
-------

Expand Down Expand Up @@ -280,3 +287,5 @@ If set to ``false``, only one ``null`` value is allowed - if a second entity
also has a ``null`` value, validation would fail.

.. include:: /reference/constraints/_payload-option.rst.inc

.. _`race conditions`: https://en.wikipedia.org/wiki/Race_condition
18 changes: 9 additions & 9 deletions service_container/compiler_passes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
How to Work with Compiler Passes
================================

Compiler passes give you an opportunity to manipulate other service
definitions that have been registered with the service container. You
can read about how to create them in the components section
":ref:`components-di-separate-compiler-passes`".
Compiler passes give you an opportunity to manipulate other
:doc:`service definitions </service_container/definitions>` that have been
registered with the service container. You can read about how to create them in
the components section ":ref:`components-di-separate-compiler-passes`".

Compiler passes are registered in the ``build()`` method of the application kernel::

Expand Down Expand Up @@ -89,8 +89,8 @@ method in the extension)::
}
}

If you are using custom service tags in a bundle then by convention, tag names
consist of the name of the bundle (lowercase, underscores as separators),
followed by a dot, and finally the "real" name. For example, if you want to
introduce some sort of "transport" tag in your AcmeMailerBundle, you should call
it ``acme_mailer.transport``.
If you are using custom :doc:`service tags </service_container/tags>` in a
bundle then by convention, tag names consist of the name of the bundle
(lowercase, underscores as separators), followed by a dot, and finally the
"real" name. For example, if you want to introduce some sort of "transport" tag
in your AcmeMailerBundle, you should call it ``acme_mailer.transport``.

0 comments on commit 6f3ef4d

Please sign in to comment.