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

option to disable override #2085

Merged
merged 2 commits into from
Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ In order to read more about upgrading and BC breaks have a look at the [UPGRADE
+ [#2068](https://github.com/luyadev/luya/issues/2068) Disabled the automatically register process of CSRF tokens. Since ActiveForms are widely used they register the CSRF token.
+ [#2081](https://github.com/luyadev/luya/pull/2081) Removed deprecated methods and/or added a deprecation error trigger.
+ [#2077](https://github.com/luyadev/luya/pull/2077) Fix issue with caching when using SVG widget and symbol names.
+ [#2085](https://github.com/luyadev/luya/pull/2085) Option to disable language override by resolved composition content in UrlManager.

## 1.9.0 (11. February 2021)

Expand Down
20 changes: 17 additions & 3 deletions core/web/UrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
*/
class UrlManager extends \yii\web\UrlManager
{
/**
* Defines whether the {{luya\web\Composition}} should override the `Yii::$app->language` from its resolved value or not. If disabled
* the Yii::$app->language won't be overriden but you can still access the resolved value with `Yii::$app->composition->langShortCode`.
*
* Disabling this option can be usefull when working with a website which does not requires the LUYA CMS and you might enable multi lingual
* content but on the same routes with a get param f.e. `?_lang=xyz` instead of `/xyz/<slug>`.
*
* @since 2.0.0
* @var boolean Whether the {{luya\web\Composition}} resolved value should override `Yii::$app->language` or not.
*/
public $overrideLanguage = true;

/**
* @var boolean Pretty urls are enabled by default and can not be turned off in luya cms context.
*/
Expand Down Expand Up @@ -96,9 +108,11 @@ public function parseRequest($request)
// @see https://github.com/luyadev/luya/issues/1146
$res = $this->routeHasLanguageCompositionPrefix($parsedRequest[0], $resolver->getResolvedKeyValue(Composition::VAR_LANG_SHORT_CODE));

// set the application language based from the parsed composition request:
Yii::$app->setLocale($this->composition->langShortCode);
Yii::$app->language = $this->composition->langShortCode;
if ($this->overrideLanguage) {
// set the application language based from the parsed composition request:
Yii::$app->setLocale($this->composition->langShortCode);
Yii::$app->language = $this->composition->langShortCode;
}

// if enableStrictParsing is enabled and the route is not found, $parsedRequest will return `false`.
if ($res === false && ($this->composition->hidden || $parsedRequest === false)) {
Expand Down