Commit 9df164d216cfd9bfc0256be56c129cb00b151344

Authored by Anastasia
2 parents 00248c31 6cd4f8ab

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	components/LanguageUrlManager.php
Showing 1 changed file with 20 additions and 5 deletions   Show diff stats
components/LanguageUrlManager.php
... ... @@ -2,23 +2,39 @@
2 2 namespace artweb\artbox\language\components;
3 3  
4 4 use artweb\artbox\language\models\Language;
  5 + use yii\web\NotFoundHttpException;
5 6 use yii\web\UrlManager;
6 7  
7 8 class LanguageUrlManager extends UrlManager
8 9 {
  10 + /**
  11 + * @var array
  12 + */
  13 + public $badGetParams = [];
  14 +
  15 + public function parseRequest($request)
  16 + {
  17 + foreach ($request->get() as $param => $value) {
  18 + if (in_array($param, $this->badGetParams)) {
  19 + throw new NotFoundHttpException();
  20 + }
  21 + }
  22 +
  23 + return parent::parseRequest($request);
  24 + }
9 25  
10 26 /**
11 27 * @inheritdoc
12 28 */
13 29 public function createUrl($params)
14 30 {
15   - if(isset( $params[ 'language_id' ] )) {
  31 + if (isset($params[ 'language_id' ])) {
16 32  
17 33 $language = Language::findOne($params[ 'language_id' ]);
18   - if($language === NULL) {
  34 + if ($language === null) {
19 35 $language = Language::getDefaultLanguage();
20 36 }
21   - unset( $params[ 'language_id' ] );
  37 + unset($params[ 'language_id' ]);
22 38 } else {
23 39  
24 40 $language = Language::getCurrent();
... ... @@ -26,8 +42,7 @@
26 42  
27 43 $url = parent::createUrl($params);
28 44  
29   -
30   - if($url == '/') {
  45 + if ($url == '/') {
31 46 return '/' . $language->url;
32 47 } else {
33 48 return '/' . $language->url . $url;
... ...