8000 Change service override docs · symfony/symfony-docs@da666af · GitHub
[go: up one dir, main page]

Skip to content

Commit da666af

Browse files
committed
Change service override docs
1 parent 66258b9 commit da666af

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

bundles/override.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,19 @@ Services & Configuration
4646
If you want to modify service definitions of another bundle, you can use a compiler
4747
pass to change the class of the service or to modify method calls. In the following
4848
example, the implementing class for the ``original-service-id`` is changed to
49-
``Acme\DemoBundle\YourService``::
49+
``App\YourService``::
5050

51-
// src/Acme/DemoBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php
52-
namespace Acme\DemoBundle\DependencyInjection\Compiler;
51+
// src/Kernel.php
52+
namespace App;
5353

54-
use Acme\DemoBundle\YourService;
55-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
54+
use App\Service\YourService;
5655
use Symfony\Component\DependencyInjection\ContainerBuilder;
5756

58-
class OverrideServiceCompilerPass implements CompilerPassInterface
57+
class Kernel extends BaseKernel
5958
{
6059
public function process(ContainerBuilder $container)
6160
{
62-
$definition = $container->getDefinition('original-service-id');
61+
$definition = $container->findDefinition('original-service-id');
6362
$definition->setClass(YourService::class);
6463
}
6564
}

0 commit comments

Comments
 (0)
0