30
30
use yii \helpers \ArrayHelper ;
31
31
use yii \i18n \PhpMessageSource ;
32
32
use yii \web \Application as WebApplication ;
33
+ use yii \web \UrlManager ;
33
34
34
35
/**
35
36
* Bootstrap class of the yii2-usuario extension. Configures container services, initializes translations,
@@ -49,10 +50,10 @@ public function bootstrap($app)
49
50
$ this ->initTranslations ($ app );
50
51
$ this ->initContainer ($ app , $ map );
51
52
$ this ->initMailServiceConfiguration ($ app , $ app ->getModule ('user ' ));
53
+ $ this ->initUrlRoutes ($ app );
52
54
53
55
if ($ app instanceof WebApplication) {
54
56
$ this ->initControllerNamespace ($ app );
55
- $ this ->initUrlRoutes ($ app );
56
57
$ this ->initUrlRestRoutes ($ app );
57
58
$ this ->initAuthCollection ($ app );
58
59
$ this ->initAuthManager ($ app );
@@ -256,11 +257,11 @@ protected function initAuthManager(Application $app)
256
257
/**
257
258
* Initializes web url routes (rules in Yii2).
258
259
*
259
- * @param WebApplication $app
260
+ * @param Application $app
260
261
*
261
262
* @throws InvalidConfigException
262
263
*/
263
- protected function initUrlRoutes (WebApplication $ app )
264
+ protected function initUrlRoutes (Application $ app )
264
265
{
265
266
/** @var $module Module */
266
267
$ module = $ app ->getModule ('user ' );
@@ -274,8 +275,13 @@ protected function initUrlRoutes(WebApplication $app)
274
275
$ config ['routePrefix ' ] = 'user ' ;
275
276
}
276
277
278
+ $ urlManager = $ app ->getUrlManager ();
279
+ if (!($ urlManager instanceof UrlManager)) {
280
+ return ;
281
+ }
282
+
277
283
$ rule = Yii::createObject ($ config );
278
- $ app -> getUrlManager () ->addRules ([$ rule ], false );
284
+ $ urlManager ->addRules ([$ rule ], false );
279
285
}
280
286
281
287
/**
0 commit comments