I redefined the owner of the HWIOAuthBundle linkedin resource because I needed to handle connection exceptions. You can use the compiler pass for this:
namespace UserAccountBundle\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('hwi_oauth.resource_owner.linkedin'); $definition->setClass('UserAccountBundle\OAuth\MyLinkedInResourceOwner'); } }
Then in your kit:
namespace UserAccountBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; use UserAccountBundle\DependencyInjection\Compiler\OverrideServiceCompilerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; class UserAccountBundle extends Bundle { public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new OverrideServiceCompilerPass()); } }
More on package redefinition: http://symfony.com/doc/current/cookbook/bundles/override.html
source share