Skip to content

Commit 8ae0222

Browse files
committed
minor #18178 [DependencyInjection] Document ServiceConfigurator remove method (alamirault)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Document `ServiceConfigurator` remove method Continue work started by `@94noni` in #17098 Fix #14854 Commits ------- 3d9dfe6 [DependencyInjection] Document ServiceConfigurator remove method
2 parents 45c4548 + 3d9dfe6 commit 8ae0222

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

service_container/remove.rst

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
How to Remove a Service
2+
=======================
3+
4+
A service can be removed from the service container if needed
5+
(for instance in the test or a specific environment):
6+
7+
.. configuration-block::
8+
9+
.. code-block:: php
10+
11+
// config/services_test.php
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use App\RemovedService;
15+
16+
return function(ContainerConfigurator $containerConfigurator) {
17+
$services = $containerConfigurator->services();
18+
19+
$services->remove(RemovedService::class);
20+
};
21+
22+
Now, the container will not contain the ``App\RemovedService``
23+
in the test environment.

0 commit comments

Comments
 (0)