Skip to content

Commit

Permalink
option to disable override (#2085)
Browse files Browse the repository at this point in the history
* option to disable override

* [skip ci]
  • Loading branch information
nadar authored Jun 13, 2021
1 parent e60f87f commit 3dbf1ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
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

0 comments on commit 3dbf1ba

Please sign in to comment.