Blame view

common/components/urlManager/LangUrlManager.php 734 Bytes
4253cbec   root   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  <?php
  /*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  
  /**
   * Description of LangUrlManager
   *
   * @author Ekstazi
   * @ver 1.2
   */
  namespace common\components\urlManager;
  use yii\web\UrlManager;
  use Yii; 
  class LangUrlManager extends UrlManager{
      public $languages=array('en');
  	public $lang='ru';
      public $langParam='language';
  
  	
  
      public function createUrl($params=array()){
  		
          if(!isset($params[$this->langParam])){ if(Yii::$app->language != $this->lang)$params[$this->langParam]=Yii::$app->language;}
  		else if($params[$this->langParam] == $this->lang)unset($params[$this->langParam]);
          return parent::createUrl($params);
      }
      //put your code here
  }