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

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

        return $navItem->id;
    }
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 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(false); // as validation is done already

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

        return $navItem->id;
    }
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 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 ( false ) ; // as validation is done already $ navItem -> nav_item_type_id = $ navItemModule -> id ; $ navItemId = $ navItem -> save ( false ) ; // as validation is done already return $ navItem -> id ; }
Create a module for a given Nav Model.

@param integer $navId
@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 navItem ID is returned.
Create a module for a given Nav Model .