public function createUrl($params)
 {
     if (isset($params['lang_id'])) {
         //Если указан идентификатор языка, то делаем попытку найти язык в БД,
         //иначе работаем с языком по умолчанию
         $lang = Lang::findOne($params['lang_id']);
         if ($lang === null) {
             $lang = Lang::getDefaultLang();
         }
         unset($params['lang_id']);
     } else {
         //Если не указан параметр языка, то работаем с текущим языком
         $lang = Lang::getCurrent();
     }
     //Получаем сформированный URL(без префикса идентификатора языка)
     $url = parent::createUrl($params);
     //Добавляем к URL префикс - буквенный идентификатор языка
     if ($url == '/') {
         return '/' . $lang->url;
     } else {
         return '/' . $lang->url . $url;
     }
 }
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         // set author_id only for new records
         if ($this->id > 0) {
             // author never changes
             unset($this->author_id);
         } else {
             //new records
             // set current user as author
             $this->author_id = \Yii::$app->user->identity->id;
             // if multylang is disabled - set as current lang
             if (!Yii::$app->controller->module->multilanguage) {
                 $this->lang_id = Lang::getDefaultLang()->id;
             }
             // publicate post if it has no custom publication and publication shedule
             if (!Yii::$app->controller->module->publication and !Yii::$app->controller->module->publicationShedule) {
                 $this->published = true;
             }
         }
         return true;
     } else {
         return false;
     }
 }