1010use Symfony \Component \HttpKernel \Event \GetResponseEvent ;
1111use Symfony \Component \HttpKernel \Log \LoggerInterface ;
1212use Symfony \Component \Security \Core \SecurityContextInterface ;
13+ use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
1314use Symfony \Component \Security \Core \Authentication \AuthenticationManagerInterface ;
1415use Symfony \Component \Security \Core \Exception \AuthenticationException ;
1516use Symfony \Component \Security \Http \SecurityEvents ;
@@ -29,16 +30,25 @@ class AutoLoginListener implements ListenerInterface
2930 /**
3031 * Constructor.
3132 *
32- * @param SecurityContextInterface $securityContext
33- * @param AuthenticationManagerInterface $authenticationManager
34- * @param string $providerKey
35- * @param string $tokenParam
36- * @param LoggerInterface $logger
37- * @param EventDispatcherInterface $dispatcher
38- * @param array $options
33+ * @param TokenStorageInterface| SecurityContextInterface $securityContext
34+ * @param AuthenticationManagerInterface $authenticationManager
35+ * @param string $providerKey
36+ * @param string $tokenParam
37+ * @param LoggerInterface $logger
38+ * @param EventDispatcherInterface $dispatcher
39+ * @param array $options
3940 */
40- public function __construct (SecurityContextInterface $ securityContext , AuthenticationManagerInterface $ authenticationManager , $ providerKey , $ tokenParam , LoggerInterface $ logger = null , EventDispatcherInterface $ dispatcher = null , array $ options = array ())
41+ public function __construct ($ securityContext , AuthenticationManagerInterface $ authenticationManager , $ providerKey , $ tokenParam , LoggerInterface $ logger = null , EventDispatcherInterface $ dispatcher = null , array $ options = array ())
4142 {
43+ if (!($ securityContext instanceof SecurityContextInterface) &&
44+ !($ securityContext instanceof TokenStorageInterface)) {
45+ throw new \InvalidArgumentException (sprintf (
46+ 'Argument 1 passed to %s() must be an instance of Symfony\Component\Security\Core\SecurityContextInterface or Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface, %s given ' ,
47+ __METHOD__ ,
48+ is_object ($ securityContext ) ? get_class ($ securityContext ) : gettype ($ securityContext )
49+ ));
50+ }
51+
4252 $ this ->securityContext = $ securityContext ;
4353 $ this ->authenticationManager = $ authenticationManager ;
4454 $ this ->providerKey = $ providerKey ;
0 commit comments