public function actionIndex() { $lang = new Lang(); $lang->scenario = 'restcreate'; $lang->attributes = ['name' => 'Deutsch', 'short_code' => 'de', 'is_default' => 0]; $lang->save(false); foreach ($this->pages as $d) { $model = new Nav(); $navItemId = $model->createPage($d['parent'], 1, 1, $d['title'], $d['alias'], 1, 'Description of ' . $d['title']); if ($navItemId) { $item = NavItem::findOne(['alias' => $d['alias']]); if ($item) { $item->nav->updateAttributes(['is_offline' => 0, 'is_hidden' => 0]); } } } foreach ($this->redirects as $redir) { $model = new Nav(); $redirItemId = $model->createRedirect($redir['parent'], 1, 1, $redir['title'], $redir['alias'], $redir['type'], $redir['typeValue'], 'Description of ' . $redir['title']); if ($redirItemId) { $item = NavItem::findOne(['alias' => $redir['alias']]); if ($item) { $item->nav->updateAttributes(['is_offline' => 0, 'is_hidden' => 0]); } } } }
/** * creates a new nav entry for the type page (nav_id will be created. * * @param array $_POST: */ public function actionCreatePage() { $fromDraft = $this->postArg('from_draft_id'); $model = new Nav(); $parentNavId = $this->postArg('parent_nav_id'); $navContainerId = $this->postArg('nav_container_id'); if (!empty($parentNavId)) { $navContainerId = Nav::findOne($parentNavId)->nav_container_id; } if (!empty($fromDraft)) { $create = $model->createPageFromDraft($parentNavId, $navContainerId, $this->postArg('lang_id'), $this->postArg('title'), $this->postArg('alias'), $this->postArg('description'), $fromDraft, $this->postArg('is_draft')); } else { $create = $model->createPage($parentNavId, $navContainerId, $this->postArg('lang_id'), $this->postArg('title'), $this->postArg('alias'), $this->postArg('layout_id'), $this->postArg('description'), $this->postArg('is_draft')); } if ($create !== true) { Yii::$app->response->statusCode = 422; } Yii::$app->menu->flushCache(); return $create; }