Skip to content

Commit 9b26fce

Browse files
DonCallistojaviereguiluz
authored andcommitted
Update compiler_passes.rst
I think that `findDefinition` is better than `getDefinition` as it will also look at aliases. I found it myself while migrating from sf < 3.4 to sf >= 3.4. In particular I was following [this](https://symfony.com/doc/current/service_container/3.3-di-changes.html) and at point 2 services managed directly by `CompilerPass` were never founded. Moreover - not related directly to this PR - I'm not sure that this "split" `getDefinition`/`findDefinition`/`getAlias` is really useful, but maybe I don't have the bigger picture. WDYT?
1 parent 3641425 commit 9b26fce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

service_container/compiler_passes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ and process the services inside the ``process()`` method::
5656
{
5757
// in this method you can manipulate the service container:
5858
// for example, changing some container service:
59-
$container->getDefinition('app.some_private_service')->setPublic(true);
59+
$container->findDefinition('app.some_private_service')->setPublic(true);
6060

6161
// or processing tagged services:
6262
foreach ($container->findTaggedServiceIds('some_tag') as $id => $tags) {

0 commit comments

Comments
 (0)