Пример #1
0
 /**
  * add page language
  * @param $id
  * @param $from
  * @param $to
  * @return \yii\web\Response
  * @throws NotFoundHttpException
  */
 public function actionAddLanguage($id, $from, $to)
 {
     $source = $this->findModel($id, $from);
     $model = new PageData();
     $model->id_page = $id;
     $model->language = $to;
     $model->title = $source->title;
     $model->description = $source->description;
     $model->content = $source->content;
     $model->keywords = $source->keywords;
     $model->status = PageData::STATUS_INACTIVE;
     if ($model->save()) {
         return $this->redirect(['update', 'id_page' => $model->id_page, 'language' => $model->language]);
     } else {
         Yii::$app->session->setFlash('error', Yii::t('app', 'Sorry, there was a problem processing your request.'));
         return $this->redirect(['update', 'id_page' => $model->{$id}, 'language' => $from]);
     }
 }