Ejemplo n.º 1
0
 public function createModuleItem($navId, $langId, $title, $alias, $moduleName, $description)
 {
     $_errors = [];
     $navItem = new NavItem();
     $navItem->parent_nav_id = self::findOne($navId)->parent_nav_id;
     $navItemModule = new \cmsadmin\models\NavItemModule();
     $navItem->attributes = ['nav_id' => $navId, 'lang_id' => $langId, 'title' => $title, 'alias' => $alias, 'description' => $description, 'nav_item_type' => 2];
     $navItemModule->attributes = ['module_name' => $moduleName];
     if (!$navItem->validate()) {
         $_errors = ArrayHelper::merge($navItem->getErrors(), $_errors);
     }
     if (!$navItemModule->validate()) {
         $_errors = ArrayHelper::merge($navItemModule->getErrors(), $_errors);
     }
     if (!empty($_errors)) {
         return $_errors;
     }
     $navItemModule->save();
     $navItem->nav_item_type_id = $navItemModule->id;
     $navItemId = $navItem->save();
     return $navItemId;
 }
Ejemplo n.º 2
0
Archivo: Nav.php Proyecto: efueger/luya
 public function createModuleItem($navId, $langId, $title, $rewrite, $moduleName)
 {
     $_errors = [];
     $navItem = new \cmsadmin\models\NavItem();
     $navItemModule = new \cmsadmin\models\NavItemModule();
     $navItem->attributes = ['nav_id' => $navId, 'lang_id' => $langId, 'title' => $title, 'rewrite' => $rewrite, 'nav_item_type' => 2];
     $navItemModule->attributes = ['module_name' => $moduleName];
     if (!$navItem->validate()) {
         $_errors = ArrayHelper::merge($navItem->getErrors(), $_errors);
     }
     if (!$navItemModule->validate()) {
         $_errors = ArrayHelper::merge($navItemModule->getErrors(), $_errors);
     }
     if (!empty($_errors)) {
         return $_errors;
     }
     $navItemModule->save();
     $navItem->nav_item_type_id = $navItemModule->id;
     $navItemId = $navItem->save();
     return $navItemId;
 }