私のサイトは他の機能と同様に認証にサードパーティのサービスを使用していますので、私はすべてのAPI呼び出しを行うサービスを設定しています。ユーザーオブジェクトにアクセスする必要があることを確認します。 私のAPIサービスにsecurity.contextサービスを注入しようとしましたが、私のユーザー認証プロバイダがAPIサービスを参照しているため(ServiceCircularReferenceExceptionが発生します)、ユーザーを認証するために必要です。 だから、私はユーザーオブジェクトを取得する別の方法でこれに苦労していると私はこのチェーンを分割する任意の明白な方法を参照することはできませんsymfony2のサービスからユーザオブジェクトを取得するにはどうすればいいですか
security.context -> authentication provider ->
user provider -> API service -> security.context
のチェーンを取得します。
私のconfigsはすべてここに、config.ymlで定義されているが、関連するビットはmyapp.user_providerは私があると推測security.ymlファイルの私のユーザープロバイダサービスとして定義したサービスである
myapp.database:
class: Pogo\MyAppBundle\Service\DatabaseService
arguments:
siteid: %siteid%
entityManager: "@doctrine.orm.entity_manager"
myapp.apiservice:
class: Pogo\MyAppBundle\Service\TicketingService
arguments:
entityManager: "@myapp.database"
myapp.user_provider:
class: Pogo\MyAppBundle\Service\APIUserProvider
arguments:
entityManager: "@myapp.database"
ticketingAdapter: "@myapp.apiservice"
securityContext: "@security.context"
myapp.authenticationprovider:
class: Pogo\MyAppBundle\Service\APIAuthenticationProvider
arguments:
userChecker: "@security.user_checker"
encoderFactory: "@security.encoder_factory"
userProvider: "@myapp.user_provider"
ですどのようにそれがsecurity.contextによって参照されているか
services.xmlやservices.yml、あるいはconfig.ymlでカスタムサービスをどのように定義していますか?あなたの設定を見ることが役立ちます。 – markymark
私の事例を更新して、私の問題を少し説明しました。あなたはアイデアを持っていますか?あるいは、ユーザーがsecurity.context経由で他のログインしているかどうかを確認する別の方法を知っていますか? – pogo