File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -82,19 +82,7 @@ public function init()
82
82
throw new InvalidConfigException ('Auth server url not configured ' );
83
83
}
84
84
$ this ->setHttpClient (new $ this ->httpClientClass );
85
-
86
- if ($ this ->cache !== false && $ this ->cache !== null ) {
87
- try {
88
- $ this ->cache = Instance::ensure (
89
- $ this ->cache ,
90
- 'yii\caching\CacheInterface '
91
- );
92
- } catch (InvalidConfigException $ e ) {
93
- Yii::warning (
94
- 'Unable to use cache for URL manager: ' . $ e ->getMessage ()
95
- );
96
- }
97
- }
85
+ $ this ->initCacheInstance ();
98
86
}
99
87
100
88
/**
@@ -204,6 +192,18 @@ public function validateRequest(Request $request)
204
192
return $ afterValidate ;
205
193
}
206
194
195
+ private function initCacheInstance ()
196
+ {
197
+ if ($ this ->cache !== false && $ this ->cache !== null && !($ this ->cache instanceof CacheInterface)) {
198
+ try {
199
+ $ this ->cache = Instance::ensure ($ this ->cache , 'yii\caching\CacheInterface ' );
200
+ } catch (InvalidConfigException $ e ) {
201
+ Yii::warning ('Unable to use cache for URL manager: ' . $ e ->getMessage ());
202
+ }
203
+ }
204
+ }
205
+
206
+
207
207
/**
208
208
* @param string $username
209
209
* @param string $password
@@ -222,6 +222,7 @@ public function requestAccessToken(
222
222
$ grantType = 'password ' ,
223
223
$ cacheTtl = 0
224
224
) {
225
+ $ this ->initCacheInstance ();
225
226
if ($ this ->testMode ) {
226
227
return TestHelper::getTokenInfo ($ rawResponse );
227
228
}
You can’t perform that action at this time.
0 commit comments