From 1c939d5cad5d87582a8bc8698f67ac003664d2dc Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 8 Oct 2024 17:38:13 +0300 Subject: [PATCH 1/2] fixed pretty-urls not working from console apps --- src/User/Bootstrap.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/User/Bootstrap.php b/src/User/Bootstrap.php index 0f5ad669..82eab2c1 100755 --- a/src/User/Bootstrap.php +++ b/src/User/Bootstrap.php @@ -30,6 +30,7 @@ use yii\helpers\ArrayHelper; use yii\i18n\PhpMessageSource; use yii\web\Application as WebApplication; +use yii\web\UrlManager; /** * Bootstrap class of the yii2-usuario extension. Configures container services, initializes translations, @@ -49,10 +50,10 @@ public function bootstrap($app) $this->initTranslations($app); $this->initContainer($app, $map); $this->initMailServiceConfiguration($app, $app->getModule('user')); + $this->initUrlRoutes($app); if ($app instanceof WebApplication) { $this->initControllerNamespace($app); - $this->initUrlRoutes($app); $this->initUrlRestRoutes($app); $this->initAuthCollection($app); $this->initAuthManager($app); @@ -256,11 +257,11 @@ protected function initAuthManager(Application $app) /** * Initializes web url routes (rules in Yii2). * - * @param WebApplication $app + * @param Application $app * * @throws InvalidConfigException */ - protected function initUrlRoutes(WebApplication $app) + protected function initUrlRoutes(Application $app) { /** @var $module Module */ $module = $app->getModule('user'); @@ -274,8 +275,13 @@ protected function initUrlRoutes(WebApplication $app) $config['routePrefix'] = 'user'; } + $urlManager = $app->getUrlManager(); + if(!($urlManager instanceof UrlManager)) { + return; + } + $rule = Yii::createObject($config); - $app->getUrlManager()->addRules([$rule], false); + $urlManager->addRules([$rule], false); } /** From 117056310b9d3f71eb9abddbcc0e3089f006e35f Mon Sep 17 00:00:00 2001 From: tonis Date: Tue, 8 Oct 2024 18:15:55 +0300 Subject: [PATCH 2/2] added changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5733c2e6..38c256a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Fix #546: The profile/show page must not be visible by default, implement configurable policy (TonisOrmisson) - Fix #397: No more fatal Exceptions when connecting to already taken Social Network (edegaudenzi) - Ehh: Added option to pre-fill recovery email via url parameter (TonisOrmisson) +- Ehh: Fixed pretty-url rules not initialized for console apps (TonisOrmisson) ## 1.6.3 Mar 18th, 2024