Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Url module controller context fix #1877

Merged
merged 14 commits into from
Nov 23, 2018
Merged
8 changes: 7 additions & 1 deletion core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. This project make usage of the [Yii Versioning Strategy](https://github.com/yiisoft/yii2/blob/master/docs/internals/versions.md). In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md).

## 1.0.15 (in progress)

### Fixed

+ [#1876](https://github.com/luyadev/luya/issues/1876) Fixed the url generation without module context when using language switcher.

## 1.0.14 (17. November 2018)

+ [#1872](https://github.com/luyadev/luya/issues/1872) Added new schemas for Json-Ld. Fixed Event Json-Ld, and TypeHinting.
Expand All @@ -18,7 +24,7 @@ All notable changes to this project will be documented in this file. This projec

## 1.0.12 (8. October 2018)

+ [#1856](https://github.com/luyadev/luya/issues/1856) If application console method is runing, the cli determination should be forced.
+ [#1856](https://github.com/luyadev/luya/issues/1856) If application console method is running, the cli determination should be forced.
+ [#1853](https://github.com/luyadev/luya/issues/1853) Add option to lazy load mocked arguments.
+ [#1852](https://github.com/luyadev/luya/pull/1852) Updated Svg widget to enable usage of symbols (svg sprite) via svg > use implementation
+ [#1851](https://github.com/luyadev/luya/issues/1851) Add string helper method highlightWord() to highlight a given word withing a string.
Expand Down
12 changes: 8 additions & 4 deletions core/web/UrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,20 @@ private function urlReplaceModule($url, $navItemId, Composition $composition)
throw new BadRequestHttpException("Unable to find nav_item_id '$navItemId' to generate the module link for url '$url'.");
}

$isOutgoingModulePage = $item->type == 2 && $moduleName !== $item->moduleName;

// 1. if the current page is a module and the requested url is not the same module, its an outgoing link to
// another module which should not be modificated.
// 2. If the current page (nav) context is the homepage, we have to keep the original link as it wont work because the homepage
// does not have a route prefix.
if (($item->type == 2 && $moduleName !== $item->moduleName) || $item->isHome) {
if ($isOutgoingModulePage || $item->isHome) {
return $url;
}

// if current controller context has an other module as the requested url, its an outgoing link to another module which should not be modificated.
if ($moduleName !== Yii::$app->controller->module->id) {

// 1. if the current page is a module and the requested url is not the same module, its an outgoing link to
// another module and ...
// 2. if current controller context has an other module as the requested url, its an outgoing link to another module which should not be modificated.
if ($isOutgoingModulePage && $moduleName !== Yii::$app->controller->module->id) {
return $url;
}

Expand Down