17
17
use FOS \OAuthServerBundle \Model \ClientManagerInterface ;
18
18
use OAuth2 \OAuth2 ;
19
19
use OAuth2 \OAuth2ServerException ;
20
- use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
21
- use Symfony \Component \DependencyInjection \ContainerInterface ;
22
20
use Symfony \Bundle \FrameworkBundle \Templating \EngineInterface ;
23
- use Symfony \Component \EventDispatcher \EventDispatcher ;
21
+ use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
24
22
use Symfony \Component \Form \Form ;
25
23
use Symfony \Component \HttpFoundation \Request ;
26
24
use Symfony \Component \HttpFoundation \RequestStack ;
37
35
*
38
36
* @author Chris Jones <[email protected] >
39
37
*/
40
- class AuthorizeController implements ContainerAwareInterface
38
+ class AuthorizeController
41
39
{
42
40
/**
43
41
* @var ClientInterface
44
42
*/
45
43
private $ client ;
46
44
47
- /**
48
- * @var ContainerInterface
49
- */
50
- protected $ container ;
51
-
52
45
/**
53
46
* @var SessionInterface
54
47
*/
@@ -100,48 +93,38 @@ class AuthorizeController implements ContainerAwareInterface
100
93
private $ templateEngineType ;
101
94
102
95
/**
103
- * @var EventDispatcher
96
+ * @var EventDispatcherInterface
104
97
*/
105
98
private $ eventDispatcher ;
106
99
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
-
117
100
/**
118
101
* 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
121
104
*
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
133
116
*/
134
117
public function __construct (
135
118
RequestStack $ requestStack ,
136
- SessionInterface $ session ,
137
119
Form $ authorizeForm ,
138
120
AuthorizeFormHandler $ authorizeFormHandler ,
139
121
OAuth2 $ oAuth2Server ,
140
122
EngineInterface $ templating ,
141
123
TokenStorageInterface $ tokenStorage ,
142
124
UrlGeneratorInterface $ router ,
143
125
ClientManagerInterface $ clientManager ,
144
- EventDispatcher $ eventDispatcher ,
126
+ EventDispatcherInterface $ eventDispatcher ,
127
+ SessionInterface $ session = null ,
145
128
$ templateEngineType = 'twig '
146
129
) {
147
130
$ this ->requestStack = $ requestStack ;
@@ -168,7 +151,7 @@ public function authorizeAction(Request $request)
168
151
throw new AccessDeniedException ('This user does not have access to this section. ' );
169
152
}
170
153
171
- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
154
+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
172
155
$ this ->session ->invalidate (600 );
173
156
$ this ->session ->set ('_fos_oauth_server.ensure_logout ' , true );
174
157
}
@@ -209,7 +192,7 @@ public function authorizeAction(Request $request)
209
192
*/
210
193
protected function processSuccess (UserInterface $ user , AuthorizeFormHandler $ formHandler , Request $ request )
211
194
{
212
- if (true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
195
+ if ($ this -> session && true === $ this ->session ->get ('_fos_oauth_server.ensure_logout ' )) {
213
196
$ this ->tokenStorage ->setToken (null );
214
197
$ this ->session ->invalidate ();
215
198
}
0 commit comments