Skip to content

Commit 905c0a4

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Improved the section about overriding bundle services Added a caution note about race conditions in EntityType
2 parents ca35570 + 03a8055 commit 905c0a4

File tree

3 files changed

+21
-28
lines changed

3 files changed

+21
-28
lines changed

bundles/override.rst

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,12 @@ before the bundle one).
4343
Services & Configuration
4444
------------------------
4545

46-
If you want to modify service definitions of another bundle, you can use a compiler
47-
pass to change the class of the service or to modify method calls. In the following
48-
example, the implementing class for the ``original-service-id`` is changed to
49-
``Acme\DemoBundle\YourService``::
50-
51-
// src/Acme/DemoBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php
52-
namespace Acme\DemoBundle\DependencyInjection\Compiler;
53-
54-
use Acme\DemoBundle\YourService;
55-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
56-
use Symfony\Component\DependencyInjection\ContainerBuilder;
57-
58-
class OverrideServiceCompilerPass implements CompilerPassInterface
59-
{
60-
public function process(ContainerBuilder $container)
61-
{
62-
$definition = $container->getDefinition('original-service-id');
63-
$definition->setClass(YourService::class);
64-
}
65-
}
66-
67-
For more information on compiler passes, see :doc:`/service_container/compiler_passes`.
46+
If you want to modify the services created by a bundle, you can use
47+
:doc:`service decoration </service_container/service_decoration>`.
48+
49+
If you want to do more advanced manipulations, like removing services created by
50+
other bundles, you must work with :doc:`service definitions </service_container/definitions>`
51+
inside a :doc:`compiler pass </service_container/compiler_passes>`.
6852

6953
Entities & Entity Mapping
7054
-------------------------

reference/constraints/UniqueEntity.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ your user table:
110110
}
111111
}
112112
113+
.. caution::
114+
115+
This constraint doesn't provide any protection against `race conditions`_.
116+
They may occur when another entity is persisted by an external process after
117+
this validation has passed and before this entity is actually persisted in
118+
the database.
119+
113120
Options
114121
-------
115122

@@ -284,3 +291,5 @@ If set to ``false``, only one ``null`` value is allowed - if a second entity
284291
also has a ``null`` value, validation would fail.
285292

286293
.. include:: /reference/constraints/_payload-option.rst.inc
294+
295+
.. _`race conditions`: https://en.wikipedia.org/wiki/Race_condition

service_container/compiler_passes.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
How to Work with Compiler Passes in Bundles
66
===========================================
77

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

1313
When using :ref:`separate compiler passes <components-di-separate-compiler-passes>`,
1414
you need to register them in the ``build()`` method of the bundle class (this
@@ -31,8 +31,8 @@ is not needed when implementing the ``process()`` method in the extension)::
3131
}
3232
}
3333

34-
One of the most common use-cases of compiler passes is to work with tagged services
35-
(read more about tags in ":doc:`/service_container/tags`"). If you are using
34+
One of the most common use-cases of compiler passes is to work with
35+
":doc:`service tags </service_container/tags>`". If you are using
3636
custom tags in a bundle then by convention, tag names consist of the name of
3737
the bundle (lowercase, underscores as separators), followed by a dot, and
3838
finally the "real" name. For example, if you want to introduce some sort of

0 commit comments

Comments
 (0)