I started to implement HWIOAuthBundle and want to create my own custom resource owner. However I'm unclear about the file/directory structure.
Where would I need to place my files to take advantage of the bundle?
I overrode the HWIOAuthBundle linkedin resource owner, because I needed to handle connection exceptions. You can use a compiler pass to do 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 bundle:
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 bundle overrides: http://symfony.com/doc/current/cookbook/bundles/override.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With