/**
  * Creates a new Page model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param string|null $language
  * @param string|null $sourceId
  * @param string|null $parentId
  * @param string|null $backUrl
  * @return mixed
  * @throws NotFoundHttpException
  */
 public function actionCreate($sourceId = null, $parentId = null, $language = null, $backUrl = null)
 {
     $model = new Page();
     $model->loadDefaultValues();
     $model->status = Page::STATUS_PUBLISHED;
     $model->language = $language ? $language : Yii::$app->language;
     if (isset($parentId)) {
         $parentCategory = $this->findModel($parentId);
         $model->parent_id = $parentCategory->id;
         if ($parentCategory->language) {
             $model->language = $parentCategory->language;
         }
     }
     if ($sourceId && $language) {
         $sourceModel = $this->findModel($sourceId);
         /** @var Page $parentItem */
         // если локализуемая тсраница имеет родителя, то пытаемся найти релевантную локализацию для родителя создаваемой страницы
         if (!($sourceModel->level > 2 && ($parentItem = @$sourceModel->parent->translations[$language]))) {
             $parentItem = Page::find()->roots()->one();
         }
         $model->parent_id = $parentItem->id;
         $model->language = $language;
         $model->translation_id = $sourceModel->translation_id;
         $model->alias = $sourceModel->alias;
         $model->status = $sourceModel->status;
         $model->preview_text = $sourceModel->preview_text;
         $model->detail_text = $sourceModel->detail_text;
         $model->metakey = $sourceModel->metakey;
         $model->metadesc = $sourceModel->metadesc;
     } else {
         $sourceModel = null;
     }
     if ($model->load(Yii::$app->request->post()) && $model->saveNode()) {
         return $this->redirect($backUrl ? $backUrl : ['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'sourceModel' => $sourceModel]);
     }
 }