4
4
5
5
namespace League \Bundle \OAuth2ServerBundle \DependencyInjection ;
6
6
7
- use DateInterval ;
8
7
use Defuse \Crypto \Key ;
9
8
use Doctrine \Bundle \DoctrineBundle \DoctrineBundle ;
10
- use Exception ;
11
9
use League \Bundle \OAuth2ServerBundle \DBAL \Type \Grant as GrantType ;
12
10
use League \Bundle \OAuth2ServerBundle \DBAL \Type \RedirectUri as RedirectUriType ;
13
11
use League \Bundle \OAuth2ServerBundle \DBAL \Type \Scope as ScopeType ;
29
27
use League \OAuth2 \Server \Grant \PasswordGrant ;
30
28
use League \OAuth2 \Server \Grant \RefreshTokenGrant ;
31
29
use League \OAuth2 \Server \ResourceServer ;
32
- use LogicException ;
33
- use RuntimeException ;
34
30
use Sensio \Bundle \FrameworkExtraBundle \SensioFrameworkExtraBundle ;
35
31
use Symfony \Bundle \SecurityBundle \SecurityBundle ;
36
32
use Symfony \Component \Config \FileLocator ;
@@ -49,7 +45,7 @@ final class LeagueOAuth2ServerExtension extends Extension implements PrependExte
49
45
/**
50
46
* {@inheritdoc}
51
47
*
52
- * @throws Exception
48
+ * @throws \ Exception
53
49
*/
54
50
public function load (array $ configs , ContainerBuilder $ container )
55
51
{
@@ -120,7 +116,7 @@ private function assertRequiredBundlesAreEnabled(ContainerBuilder $container): v
120
116
121
117
foreach ($ requiredBundles as $ bundleAlias => $ requiredBundle ) {
122
118
if (!$ container ->hasExtension ($ bundleAlias )) {
123
- throw new LogicException (sprintf ('Bundle \'%s \' needs to be enabled in your application kernel. ' , $ requiredBundle ));
119
+ throw new \ LogicException (sprintf ('Bundle \'%s \' needs to be enabled in your application kernel. ' , $ requiredBundle ));
124
120
}
125
121
}
126
122
}
@@ -139,7 +135,7 @@ private function configureAuthorizationServer(ContainerBuilder $container, array
139
135
$ authorizationServer ->replaceArgument ('$encryptionKey ' , $ config ['encryption_key ' ]);
140
136
} elseif ('defuse ' === $ config ['encryption_key_type ' ]) {
141
137
if (!class_exists (Key::class)) {
142
- throw new RuntimeException ('You must install the "defuse/php-encryption" package to use "encryption_key_type: defuse". ' );
138
+ throw new \ RuntimeException ('You must install the "defuse/php-encryption" package to use "encryption_key_type: defuse". ' );
143
139
}
144
140
145
141
$ keyDefinition = (new Definition (Key::class))
@@ -153,35 +149,35 @@ private function configureAuthorizationServer(ContainerBuilder $container, array
153
149
if ($ config ['enable_client_credentials_grant ' ]) {
154
150
$ authorizationServer ->addMethodCall ('enableGrantType ' , [
155
151
new Reference (ClientCredentialsGrant::class),
156
- new Definition (DateInterval::class, [$ config ['access_token_ttl ' ]]),
152
+ new Definition (\ DateInterval::class, [$ config ['access_token_ttl ' ]]),
157
153
]);
158
154
}
159
155
160
156
if ($ config ['enable_password_grant ' ]) {
161
157
$ authorizationServer ->addMethodCall ('enableGrantType ' , [
162
158
new Reference (PasswordGrant::class),
163
- new Definition (DateInterval::class, [$ config ['access_token_ttl ' ]]),
159
+ new Definition (\ DateInterval::class, [$ config ['access_token_ttl ' ]]),
164
160
]);
165
161
}
166
162
167
163
if ($ config ['enable_refresh_token_grant ' ]) {
168
164
$ authorizationServer ->addMethodCall ('enableGrantType ' , [
169
165
new Reference (RefreshTokenGrant::class),
170
- new Definition (DateInterval::class, [$ config ['access_token_ttl ' ]]),
166
+ new Definition (\ DateInterval::class, [$ config ['access_token_ttl ' ]]),
171
167
]);
172
168
}
173
169
174
170
if ($ config ['enable_auth_code_grant ' ]) {
175
171
$ authorizationServer ->addMethodCall ('enableGrantType ' , [
176
172
new Reference (AuthCodeGrant::class),
177
- new Definition (DateInterval::class, [$ config ['access_token_ttl ' ]]),
173
+ new Definition (\ DateInterval::class, [$ config ['access_token_ttl ' ]]),
178
174
]);
179
175
}
180
176
181
177
if ($ config ['enable_implicit_grant ' ]) {
182
178
$ authorizationServer ->addMethodCall ('enableGrantType ' , [
183
179
new Reference (ImplicitGrant::class),
184
- new Definition (DateInterval::class, [$ config ['access_token_ttl ' ]]),
180
+ new Definition (\ DateInterval::class, [$ config ['access_token_ttl ' ]]),
185
181
]);
186
182
}
187
183
@@ -193,21 +189,21 @@ private function configureGrants(ContainerBuilder $container, array $config): vo
193
189
$ container
194
190
->getDefinition (PasswordGrant::class)
195
191
->addMethodCall ('setRefreshTokenTTL ' , [
196
- new Definition (DateInterval::class, [$ config ['refresh_token_ttl ' ]]),
192
+ new Definition (\ DateInterval::class, [$ config ['refresh_token_ttl ' ]]),
197
193
])
198
194
;
199
195
200
196
$ container
201
197
->getDefinition (RefreshTokenGrant::class)
202
198
->addMethodCall ('setRefreshTokenTTL ' , [
203
- new Definition (DateInterval::class, [$ config ['refresh_token_ttl ' ]]),
199
+ new Definition (\ DateInterval::class, [$ config ['refresh_token_ttl ' ]]),
204
200
])
205
201
;
206
202
207
203
$ authCodeGrantDefinition = $ container ->getDefinition (AuthCodeGrant::class);
208
- $ authCodeGrantDefinition ->replaceArgument ('$authCodeTTL ' , new Definition (DateInterval::class, [$ config ['auth_code_ttl ' ]]))
204
+ $ authCodeGrantDefinition ->replaceArgument ('$authCodeTTL ' , new Definition (\ DateInterval::class, [$ config ['auth_code_ttl ' ]]))
209
205
->addMethodCall ('setRefreshTokenTTL ' , [
210
- new Definition (DateInterval::class, [$ config ['refresh_token_ttl ' ]]),
206
+ new Definition (\ DateInterval::class, [$ config ['refresh_token_ttl ' ]]),
211
207
])
212
208
;
213
209
@@ -217,17 +213,17 @@ private function configureGrants(ContainerBuilder $container, array $config): vo
217
213
218
214
$ container
219
215
->getDefinition (ImplicitGrant::class)
220
- ->replaceArgument ('$accessTokenTTL ' , new Definition (DateInterval::class, [$ config ['access_token_ttl ' ]]))
216
+ ->replaceArgument ('$accessTokenTTL ' , new Definition (\ DateInterval::class, [$ config ['access_token_ttl ' ]]))
221
217
;
222
218
}
223
219
224
220
/**
225
- * @throws Exception
221
+ * @throws \ Exception
226
222
*/
227
223
private function configurePersistence (LoaderInterface $ loader , ContainerBuilder $ container , array $ config ): void
228
224
{
229
225
if (\count ($ config ) > 1 ) {
230
- throw new LogicException ('Only one persistence method can be configured at a time. ' );
226
+ throw new \ LogicException ('Only one persistence method can be configured at a time. ' );
231
227
}
232
228
233
229
$ persistenceConfiguration = current ($ config );
0 commit comments