public function createModule($parentNavId, $navContainerId, $langId, $title, $alias, $moduleName, $description)
    {
        $_errors = [];

        $nav = $this;
        $navItem = new NavItem();
        $navItem->parent_nav_id = $parentNavId;
        $navItemModule = new NavItemModule();

        $nav->attributes = [
            'parent_nav_id' => $parentNavId,
            'nav_container_id' => $navContainerId,
            'is_hidden' => true,
            'is_offline' => true,
        ];
        
        $navItem->attributes = [
            'lang_id' => $langId,
            'title' => $title,
            'alias' => $alias,
            'description' => $description,
            'nav_item_type' => 2
        ];
        
        $navItemModule->attributes = ['module_name' => $moduleName];

        if (!$nav->validate()) {
            $_errors = ArrayHelper::merge($nav->getErrors(), $_errors);
        }
        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(false); // as validation is done already
        $nav->save(false); // as validation is done already

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

        return $nav->id;
    }
public function createModule($parentNavId, $navContainerId, $langId, $title, $alias, $moduleName, $description)
    {
        $_errors = [];

        $nav = $this;
        $navItem = new NavItem();
        $navItem->parent_nav_id = $parentNavId;
        $navItemModule = new NavItemModule();

        $nav->attributes = [
            'parent_nav_id' => $parentNavId,
            'nav_container_id' => $navContainerId,
            'is_hidden' => true,
            'is_offline' => true,
        ];
        
        $navItem->attributes = [
            'lang_id' => $langId,
            'title' => $title,
            'alias' => $alias,
            'description' => $description,
            'nav_item_type' => 2
        ];
        
        $navItemModule->attributes = ['module_name' => $moduleName];

        if (!$nav->validate()) {
            $_errors = ArrayHelper::merge($nav->getErrors(), $_errors);
        }
        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(false); // as validation is done already
        $nav->save(false); // as validation is done already

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

        return $nav->id;
    }
public function createModule ( $ parentNavId , $ navContainerId , $ langId , $ title , $ alias , $ moduleName , $ description ) { $ _errors = [ ] ; $ nav = $ this ; $ navItem = new NavItem ( ) ; $ navItem -> parent_nav_id = $ parentNavId ; $ navItemModule = new NavItemModule ( ) ; $ nav -> attributes = [ 'parent_nav_id' => $ parentNavId , 'nav_container_id' => $ navContainerId , 'is_hidden' => true , 'is_offline' => true , ] ; $ navItem -> attributes = [ 'lang_id' => $ langId , 'title' => $ title , 'alias' => $ alias , 'description' => $ description , 'nav_item_type' => 2 ] ; $ navItemModule -> attributes = [ 'module_name' => $ moduleName ] ; if ( ! $ nav -> validate ( ) ) { $ _errors = ArrayHelper :: merge ( $ nav -> getErrors ( ) , $ _errors ) ; } 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 ( false ) ; // as validation is done already $ nav -> save ( false ) ; // as validation is done already $ navItem -> nav_item_type_id = $ navItemModule -> id ; $ navItem -> nav_id = $ nav -> id ; $ navItemId = $ navItem -> save ( false ) ; // as validation is done already return $ nav -> id ; }
Create a new Module Page.

@param integer $parentNavId
@param integer $navContainerId
@param integer $langId
@param string $title
@param string $alias
@param string $moduleName
@param string $description
@return array|integer If an array is returned the validationed failed, the array contains the error messages. If sucess the nav ID is returned.
Create a new Module Page .