2017-12-23 55 views
0

를 만들려고 오류,심포니 4 - 내가 <a href="https://symfony.com/doc/master/session/proxy_examples.html" rel="nofollow noreferrer">https://symfony.com/doc/master/session/proxy_examples.html</a>의 지침에 따라 세션 프록시

내가 업데이트 내 framework.yaml

framework: 
    secret: '%env(APP_SECRET)%' 
    #default_locale: en 
    #csrf_protection: ~ 
    #http_method_override: true 

# uncomment this entire section to enable sessions 
session: 
    # With this config, PHP's native session handling is used 
    handler_id: App\Session\CookieEncryptedSession 

#esi: ~ 
#fragments: ~ 
php_errors: 
    log: true 

나는 또한 내 ownclass 만들 :

<?php 
namespace App\Session; 

use Defuse\Crypto\Crypto; 
use Defuse\Crypto\Key; 
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; 

class CookieEncryptedSession extends SessionHandlerProxy 
{ 
    private $key; 

    public function __construct(\SessionHandlerInterface $handler, Key $key) 
    { 
    $this->key = $key; 

    parent::__construct($handler); 
    } 

    public function read($id) 
    { 
    $data = parent::read($id); 

    return Crypto::decrypt($data, $this->key); 
    } 

    public function write($id, $data) 
    { 
    $data = Crypto::encrypt($data, $this->key); 

    return parent::write($id, $data); 
    } 
} 

콘솔로 서버를 실행하려고하면이 오류가 발생합니다.

In CheckCircularReferencesPass.php line 67: 

    Circular reference detected for service "App\Session\CookieEncryptedSession 
    ", path: "App\Session\CookieEncryptedSession -> App\Session\CookieEncrypted 
    Session".  

실수는 어디에서 왔습니까?

감사

오스카

답변

0

에서 autowiring이 서비스가 생성자에 필요한 인터페이스를 구현 자체에 서비스를 주입하기 위해 노력하고있다. CookieEncryptedSession 구현은 SessionHandlerInterface를 통해 : 당신의 서비스에

class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface 

설치 서비스 : CookieEncryptedSession 당신은 당신이 원하는 SessionHandlerInterface 서비스를 선택할 수 있습니다 수동 있도록.

  • NativeSessionHandler
  • NativeFileSessionHandler
  • DbalSessionHandler
  • 기타