1717use FOS \OAuthServerBundle \Model \ClientManagerInterface ;
1818use OAuth2 \OAuth2 ;
1919use OAuth2 \OAuth2ServerException ;
20- use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
21- use Symfony \Component \DependencyInjection \ContainerInterface ;
2220use Symfony \Bundle \FrameworkBundle \Templating \EngineInterface ;
23- use Symfony \Component \EventDispatcher \EventDispatcher ;
21+ use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
2422use Symfony \Component \Form \Form ;
2523use Symfony \Component \HttpFoundation \Request ;
2624use Symfony \Component \HttpFoundation \RequestStack ;
3735 *
3836 * @author Chris Jones <leeked@gmail.com>
3937 */
40- class AuthorizeController implements ContainerAwareInterface
38+ class AuthorizeController
4139{
4240 /**
4341 * @var ClientInterface
4442 */
4543 private $ client ;
4644
47- /**
48- * @var ContainerInterface
49- */
50- protected $ container ;
51-
5245 /**
5346 * @var SessionInterface
5447 */
@@ -100,48 +93,38 @@ class AuthorizeController implements ContainerAwareInterface
10093 private $ templateEngineType ;
10194
10295 /**
103- * @var EventDispatcher
96+ * @var EventDispatcherInterface
10497 */
10598 private $ eventDispatcher ;
10699
107- /**
108- * Sets the container.
109- *
110- * @param ContainerInterface|null $container A ContainerInterface instance or null
111- */
112- public function setContainer (ContainerInterface $ container = null )
113- {
114- $ this ->container = $ container ;
115- }
116-
117100 /**
118101 * This controller had been made as a service due to support symfony 4 where all* services are private by default.
119- * Thus, there is considered a bad practice to fetch services directly from container.
120- * @todo This controller could be refactored to do not rely on so many dependencies
102+ * Thus, this is considered a bad practice to fetch services directly from container.
103+ * @todo This controller could be refactored to not rely on so many dependencies
121104 *
122- * @param RequestStack $requestStack
123- * @param SessionInterface $session
124- * @param Form $authorizeForm
125- * @param AuthorizeFormHandler $authorizeFormHandler
126- * @param OAuth2 $oAuth2Server
127- * @param EngineInterface $templating
128- * @param TokenStorageInterface $tokenStorage
129- * @param UrlGeneratorInterface $router
130- * @param ClientManagerInterface $clientManager
131- * @param EventDispatcher $eventDispatcher
132- * @param string $templateEngineType
105+ * @param RequestStack $requestStack
106+ * @param Form $authorizeForm
107+ * @param AuthorizeFormHandler $authorizeFormHandler
108+ * @param OAuth2 $oAuth2Server
109+ * @param EngineInterface $templating
110+ * @param TokenStorageInterface $tokenStorage
111+ * @param UrlGeneratorInterface $router
112+ * @param ClientManagerInterface $clientManager
113+ * @param EventDispatcherInterface $eventDispatcher
114+ * @param SessionInterface $session
115+ * @param string $templateEngineType
133116 */
134117 public function __construct (
135118 RequestStack $ requestStack ,
136- SessionInterface $ session ,
137119 Form $ authorizeForm ,
138120 AuthorizeFormHandler $ authorizeFormHandler ,
139121 OAuth2 $ oAuth2Server ,
140122 EngineInterface $ templating ,
141123 TokenStorageInterface $ tokenStorage ,
142124 UrlGeneratorInterface $ router ,
143125 ClientManagerInterface $ clientManager ,
144- EventDispatcher $ eventDispatcher ,
126+ EventDispatcherInterface $ eventDispatcher ,
127+ SessionInterface $ session = null ,
145128 $ templateEngineType = 'twig '
146129 ) {
147130 $ this ->requestStack = $ requestStack ;
@@ -168,7 +151,7 @@ public function authorizeAction(Request $request)
168151 throw new AccessDeniedException ('This user does not have access to this section. ' );
169152 }
170153
171- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
154+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
172155 $ this ->session ->invalidate (600 );
173156 $ this ->session ->set ('_fos_oauth_server.ensure_logout ' , true );
174157 }
@@ -209,7 +192,7 @@ public function authorizeAction(Request $request)
209192 */
210193 protected function processSuccess (UserInterface $ user , AuthorizeFormHandler $ formHandler , Request $ request )
211194 {
212- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
195+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
213196 $ this ->tokenStorage ->setToken (null );
214197 $ this ->session ->invalidate ();
215198 }
0 commit comments