Reputation: 1568
I'm searching how to override a component of symfony. In my specific case I would like to override the MessageCatalogue class of the Translation component to be able to send event when no translations have been found. Is this even possible ?
Upvotes: 1
Views: 537
Reputation: 2333
Yes, it is. Here's a detailed guide on how to override any part of a bundle. The first example shows what you are looking for.
// src/Acme/DemoBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php
namespace Acme\DemoBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class OverrideServiceCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$definition = $container->getDefinition('original-service-id');
$definition->setClass('Acme\DemoBundle\YourService');
}
}
However, xabbuh's comment on your question seems to be an easier solution.
Upvotes: 2