Skip to content

Commit

Permalink
Merge 41b3192 into 610acf7
Browse files Browse the repository at this point in the history
  • Loading branch information
denyadzi committed Jan 21, 2019
2 parents 610acf7 + 41b3192 commit 305fbe4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. This projec

### Fixed

+ [#1902](https://github.com/luyadev/luya/pull/1902) Composition component hides alternate url lang codes when hideDefaultPrefixOnly is true and current lang code is default.
+ [#1898](https://github.com/luyadev/luya/issues/1898) Telephone link raises an exception if an invalid telephone number is provided.
+ [#1897](https://github.com/luyadev/luya/issues/1897) Yii_* constants where not available in config files as Yii entry script was loaded after config files.
+ [#1888](https://github.com/luyadev/luya/issues/1888) Fixed issue with range values which can have float values.
Expand Down
7 changes: 6 additions & 1 deletion core/web/Composition.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ public function getPrefixPath()
*/
public function createRouteEnsure(array $overrideKeys = [])
{
return $this->hidden || (!$this->hidden && $this->langShortCode == $this->defaultLangShortCode && $this->hideDefaultPrefixOnly) ? '' : $this->createRoute($overrideKeys);
if (isset($overrideKeys['langShortCode'])) {
$langShortCode = $overrideKeys['langShortCode'];
} else {
$langShortCode = $this->langShortCode;
}
return $this->hidden || (!$this->hidden && $langShortCode == $this->defaultLangShortCode && $this->hideDefaultPrefixOnly) ? '' : $this->createRoute($overrideKeys);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions tests/core/web/CompositionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,5 +317,15 @@ public function testHideDefaultPrefixOnly()
$this->assertSame('de', $composition->createRouteEnsure()); // is not hidden cause default is `en` and provided in the url is `de/hello/world`.
$composition = new Composition($request, ['hidden' => false, 'hideDefaultPrefixOnly' => true, 'default' => ['langShortCode' => 'de']]);
$this->assertSame('', $composition->createRouteEnsure()); // is default `de` and also provided in the url `de/hello/world`

// not hidden while overriding with alternative to current lang code
$request = new Request(['hostInfo' => 'http://localhost', 'pathInfo' => 'de/hello/world']);
$composition = new Composition($request, ['hidden' => false, 'hideDefaultPrefixOnly' => true, 'default' => ['langShortCode' => 'de']]);
$this->assertSame('fr', $composition->createRouteEnsure(['langShortCode' => 'fr']));

// hidden while overriding with alternative to current, but equal to default lang code
$request = new Request(['hostInfo' => 'http://localhost', 'pathInfo' => 'de/hello/world']);
$composition = new Composition($request, ['hidden' => false, 'hideDefaultPrefixOnly' => true, 'default' => ['langShortCode' => 'en']]);
$this->assertSame('', $composition->createRouteEnsure(['langShortCode' => 'en']));
}
}

0 comments on commit 305fbe4

Please sign in to comment.