私はHWIOAuthBundleの実装を開始し、独自のカスタムリソースオーナーを作成したいと考えています。しかし、私はファイル/ディレクトリ構造については不明です。Symfony 2 | HWIOAuthBundle - カスタムリソースオーナーを作成するには?
バンドルを利用するにはどこにファイルを置く必要がありますか?
私はHWIOAuthBundleの実装を開始し、独自のカスタムリソースオーナーを作成したいと考えています。しかし、私はファイル/ディレクトリ構造については不明です。Symfony 2 | HWIOAuthBundle - カスタムリソースオーナーを作成するには?
バンドルを利用するにはどこにファイルを置く必要がありますか?
バンドルは、バンドルを直接編集することなくカスタムリソース所有者をサポートしていないようです(これは一見しただけですが、実際にこのバンドルを使用したことはありません)。
oauth.xmlファイル(https://github.com/hwi/HWIOAuthBundle/blob/master/Resources/config/oauth.xml)は、それぞれの既存のリソース所有者にリンクしていますので、ここにリンクされているものを参考にしてください。
bundle documentationによれば、これを行うことができます。
GenericOauth2ResourceOwnerクラスは、ベンダーバンドルディレクトリHWI \ Bundle \ OAuthBundle \ OAuth \ ResourceOwnerにあります。
私は接続の例外を処理する必要があったため、HWIOAuthBundle linkedinリソースの所有者をオーバーロードしました。あなたのバンドルに続いて
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');
}
}
: これを行うには、コンパイラのパスを使用することができます
バンドルオーバーライドの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());
}
}
より: http://symfony.com/doc/current/cookbook/bundles/override.html
私はそれは素晴らしいこのように動作することを確認します! – Bruno