Exemplo n.º 1
0
 public function createPageItem($navId, $langId, $title, $alias, $layoutId, $description)
 {
     $_errors = [];
     $navItem = new NavItem();
     $navItem->parent_nav_id = self::findOne($navId)->parent_nav_id;
     $navItemPage = new \cmsadmin\models\NavItemPage();
     $navItem->attributes = ['nav_id' => $navId, 'lang_id' => $langId, 'title' => $title, 'alias' => $alias, 'description' => $description, 'nav_item_type' => 1];
     $navItemPage->attributes = ['layout_id' => $layoutId];
     if (!$navItem->validate()) {
         $_errors = ArrayHelper::merge($navItem->getErrors(), $_errors);
     }
     if (!$navItemPage->validate()) {
         $_errors = ArrayHelper::merge($navItemPage->getErrors(), $_errors);
     }
     if (!empty($_errors)) {
         return $_errors;
     }
     $navItemPage->save();
     $navItem->nav_item_type_id = $navItemPage->id;
     $navItemId = $navItem->save();
     return $navItemId;
 }
Exemplo n.º 2
0
Arquivo: Nav.php Projeto: efueger/luya
 public function createPageItem($navId, $langId, $title, $rewrite, $layoutId)
 {
     $_errors = [];
     $navItem = new \cmsadmin\models\NavItem();
     $navItemPage = new \cmsadmin\models\NavItemPage();
     $navItem->attributes = ['nav_id' => $navId, 'lang_id' => $langId, 'title' => $title, 'rewrite' => $rewrite, 'nav_item_type' => 1];
     $navItemPage->attributes = ['layout_id' => $layoutId];
     if (!$navItem->validate()) {
         $_errors = ArrayHelper::merge($navItem->getErrors(), $_errors);
     }
     if (!$navItemPage->validate()) {
         $_errors = ArrayHelper::merge($navItemPage->getErrors(), $_errors);
     }
     if (!empty($_errors)) {
         return $_errors;
     }
     $navItemPage->save();
     $navItem->nav_item_type_id = $navItemPage->id;
     $navItemId = $navItem->save();
     return $navItemId;
 }