Beispiel #1
0
 /**
  *
  * @param unknown $navId
  * @param unknown $langId
  * @param unknown $title
  * @param unknown $alias
  * @param unknown $redirectType The type of redirect (1 = page, 2 = URL, 3 = Link to File)
  * @param unknown $redirectTypeValue Depending on the type (1 = cms_nav.id, 2 = http://luya.io)
  * @param unknown $description
  * @return boolean
  */
 public function createRedirectItem($navId, $langId, $title, $alias, $redirectType, $redirectTypeValue, $description)
 {
     $_errors = [];
     $navItem = new NavItem();
     $navItem->parent_nav_id = self::findOne($navId)->parent_nav_id;
     $navItemRedirect = new NavItemRedirect();
     $navItem->attributes = ['nav_id' => $navId, 'lang_id' => $langId, 'title' => $title, 'alias' => $alias, 'description' => $description, 'nav_item_type' => 3];
     $navItemRedirect->attributes = ['type' => $redirectType, 'value' => $redirectTypeValue];
     if (!$navItem->validate()) {
         $_errors = ArrayHelper::merge($navItem->getErrors(), $_errors);
     }
     if (!$navItemRedirect->validate()) {
         $_errors = ArrayHelper::merge($navItemRedirect->getErrors(), $_errors);
     }
     if (!empty($_errors)) {
         return $_errors;
     }
     $navItemRedirect->save();
     $navItem->nav_item_type_id = $navItemRedirect->id;
     $navItemId = $navItem->save();
     return $navItemId;
 }