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 NavItemPage();

        $navItem->attributes = [
            'nav_id' => $navId,
            'lang_id' => $langId,
            'title' => $title,
            'alias' => $alias,
            'description' => $description,
            'nav_item_type' => 1,
        ];
        
        $navItemPage->attributes = [
            'nav_item_id' => 0,
            'layout_id' => $layoutId,
            'create_user_id' => Module::getAuthorUserId(),
            'timestamp_create' => time(),
            'version_alias' => Module::VERSION_INIT_LABEL,
        ];

        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(false); // as validation is done already

        $navItem->nav_item_type_id = $navItemPage->id;
        $navItemId = $navItem->save(false); // as validation is done already

        $navItemPage->updateAttributes(['nav_item_id' => $navItem->id]);
        
        return $navItem->id;
    }
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 NavItemPage();

        $navItem->attributes = [
            'nav_id' => $navId,
            'lang_id' => $langId,
            'title' => $title,
            'alias' => $alias,
            'description' => $description,
            'nav_item_type' => 1,
        ];
        
        $navItemPage->attributes = [
            'nav_item_id' => 0,
            'layout_id' => $layoutId,
            'create_user_id' => Module::getAuthorUserId(),
            'timestamp_create' => time(),
            'version_alias' => Module::VERSION_INIT_LABEL,
        ];

        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(false); // as validation is done already

        $navItem->nav_item_type_id = $navItemPage->id;
        $navItemId = $navItem->save(false); // as validation is done already

        $navItemPage->updateAttributes(['nav_item_id' => $navItem->id]);
        
        return $navItem->id;
    }
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 NavItemPage ( ) ; $ navItem -> attributes = [ 'nav_id' => $ navId , 'lang_id' => $ langId , 'title' => $ title , 'alias' => $ alias , 'description' => $ description , 'nav_item_type' => 1 , ] ; $ navItemPage -> attributes = [ 'nav_item_id' => 0 , 'layout_id' => $ layoutId , 'create_user_id' => Module :: getAuthorUserId ( ) , 'timestamp_create' => time ( ) , 'version_alias' => Module :: VERSION_INIT_LABEL , ] ; 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 ( false ) ; // as validation is done already $ navItem -> nav_item_type_id = $ navItemPage -> id ; $ navItemId = $ navItem -> save ( false ) ; // as validation is done already $ navItemPage -> updateAttributes ( [ 'nav_item_id' => $ navItem -> id ] ) ; return $ navItem -> id ; }
Create a nav item for a given NavId.

If an array occurs an array with all errors is returned, if success the NavItem id is returned.

@param integer $navId
@param integer $langId
@param string $title
@param string $alias
@param integer $layoutId
@param string $description
@return array|integer If an array is returned the validationed failed, the array contains the error messages. If sucess the navItem ID is returned.
Create a nav item for a given NavId .