8000 Change service override docs by weaverryan · Pull Request #8728 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Change service override docs #8728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 24, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions bundles/override.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,19 @@ 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
``Acme\DemoBundle\YourService``::
``App\YourService``::

// src/Acme/DemoBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php
namespace Acme\DemoBundle\DependencyInjection\Compiler;
// src/Kernel.php
namespace App;

use Acme\DemoBundle\YourService;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use App\Service\YourService;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class OverrideServiceCompilerPass implements CompilerPassInterface
class Kernel extends BaseKernel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the use statement is missing

{
public function process(ContainerBuilder $container)
{
$definition = $container->getDefinition('original-service-id');
$definition = $container->findDefinition('original-service-id');
$definition->setClass(YourService::class);
}
}
Expand Down
0