public function processCMSNavItems(Plugin $plugin, &$log = '', $xml = false)
    {
        if (!$xml)
            $xml = $this->loadXML($plugin->Path);

        if(!$xml)
            throw new Exception('Missing plugin.xml file for plugin ['.$plugin->Slug.']');

        $processedSlugs = array();
        // add cmsnavitems
        $navitems = $xml->cmsnavitems;
        if (!empty($navitems)) {
            foreach ( $navitems->item as $xml_item ) {
                $cms_nav_item = new CMSNavItem();
                $this->ModelMapper->defaultsOnModel($cms_nav_item);
                $cms_nav_item = $this->SystemXMLConverter->xmlToCMSNavItem($cms_nav_item, $xml_item);

                if ($this->insertCMSNavItem($cms_nav_item, $plugin)) {
                    $log .= "CMSNavItem created...\n";
                    $log .= "ID: {$cms_nav_item->CMSNavItemID}\n";
                    $log .= "Slug: {$cms_nav_item->Slug}\n";
                    $log .= "Label: {$cms_nav_item->Label}\n";
                    $log .= "URI: {$cms_nav_item->URI}\n";
                    $log .= "\n";
                }

                $processedSlugs[] = $cms_nav_item->Slug;
                foreach($cms_nav_item->getChildren() as $child) {
                    if ($this->insertCMSNavItem($child, $plugin)) {
                        $log .= "CMSNavItem created...\n";
                        $log .= "ID: {$child->CMSNavItemID}\n";
                        $log .= "Slug: {$child->Slug}\n";
                        $log .= "Label: {$child->Label}\n";
                        $log .= "URI: {$child->URI}\n";
                        $log .= "\n";
                    }

                    $processedSlugs[] = $child->Slug;
                }
            }
        }

        if($plugin->PluginID == '')
            return;

        $existing = $this->CMSNavItemService->findAll(new DTO(array('PluginID' => $plugin->PluginID)))->getResults();
        foreach($existing as $e)
        {
            if(!in_array($e->Slug, $processedSlugs))
                $this->CMSNavItemService->delete($e->Slug);
        }

    }
public function processCMSNavItems(Plugin $plugin, &$log = '', $xml = false)
    {
        if (!$xml)
            $xml = $this->loadXML($plugin->Path);

        if(!$xml)
            throw new Exception('Missing plugin.xml file for plugin ['.$plugin->Slug.']');

        $processedSlugs = array();
        // add cmsnavitems
        $navitems = $xml->cmsnavitems;
        if (!empty($navitems)) {
            foreach ( $navitems->item as $xml_item ) {
                $cms_nav_item = new CMSNavItem();
                $this->ModelMapper->defaultsOnModel($cms_nav_item);
                $cms_nav_item = $this->SystemXMLConverter->xmlToCMSNavItem($cms_nav_item, $xml_item);

                if ($this->insertCMSNavItem($cms_nav_item, $plugin)) {
                    $log .= "CMSNavItem created...\n";
                    $log .= "ID: {$cms_nav_item->CMSNavItemID}\n";
                    $log .= "Slug: {$cms_nav_item->Slug}\n";
                    $log .= "Label: {$cms_nav_item->Label}\n";
                    $log .= "URI: {$cms_nav_item->URI}\n";
                    $log .= "\n";
                }

                $processedSlugs[] = $cms_nav_item->Slug;
                foreach($cms_nav_item->getChildren() as $child) {
                    if ($this->insertCMSNavItem($child, $plugin)) {
                        $log .= "CMSNavItem created...\n";
                        $log .= "ID: {$child->CMSNavItemID}\n";
                        $log .= "Slug: {$child->Slug}\n";
                        $log .= "Label: {$child->Label}\n";
                        $log .= "URI: {$child->URI}\n";
                        $log .= "\n";
                    }

                    $processedSlugs[] = $child->Slug;
                }
            }
        }

        if($plugin->PluginID == '')
            return;

        $existing = $this->CMSNavItemService->findAll(new DTO(array('PluginID' => $plugin->PluginID)))->getResults();
        foreach($existing as $e)
        {
            if(!in_array($e->Slug, $processedSlugs))
                $this->CMSNavItemService->delete($e->Slug);
        }

    }
public function processCMSNavItems ( Plugin $ plugin , & $ log = '' , $ xml = false ) { if ( ! $ xml ) $ xml = $ this -> loadXML ( $ plugin -> Path ) ; if ( ! $ xml ) throw new Exception ( 'Missing plugin.xml file for plugin [' . $ plugin -> Slug . ']' ) ; $ processedSlugs = array ( ) ; // add cmsnavitems $ navitems = $ xml -> cmsnavitems ; if ( ! empty ( $ navitems ) ) { foreach ( $ navitems -> item as $ xml_item ) { $ cms_nav_item = new CMSNavItem ( ) ; $ this -> ModelMapper -> defaultsOnModel ( $ cms_nav_item ) ; $ cms_nav_item = $ this -> SystemXMLConverter -> xmlToCMSNavItem ( $ cms_nav_item , $ xml_item ) ; if ( $ this -> insertCMSNavItem ( $ cms_nav_item , $ plugin ) ) { $ log .= "CMSNavItem created...\n" ; $ log .= "ID: {$cms_nav_item->CMSNavItemID}\n" ; $ log .= "Slug: {$cms_nav_item->Slug}\n" ; $ log .= "Label: {$cms_nav_item->Label}\n" ; $ log .= "URI: {$cms_nav_item->URI}\n" ; $ log .= "\n" ; } $ processedSlugs [ ] = $ cms_nav_item -> Slug ; foreach ( $ cms_nav_item -> getChildren ( ) as $ child ) { if ( $ this -> insertCMSNavItem ( $ child , $ plugin ) ) { $ log .= "CMSNavItem created...\n" ; $ log .= "ID: {$child->CMSNavItemID}\n" ; $ log .= "Slug: {$child->Slug}\n" ; $ log .= "Label: {$child->Label}\n" ; $ log .= "URI: {$child->URI}\n" ; $ log .= "\n" ; } $ processedSlugs [ ] = $ child -> Slug ; } } } if ( $ plugin -> PluginID == '' ) return ; $ existing = $ this -> CMSNavItemService -> findAll ( new DTO ( array ( 'PluginID' => $ plugin -> PluginID ) ) ) -> getResults ( ) ; foreach ( $ existing as $ e ) { if ( ! in_array ( $ e -> Slug , $ processedSlugs ) ) $ this -> CMSNavItemService -> delete ( $ e -> Slug ) ; } }
Add all the CMS nav items from the plugin

@param Plugin            $plugin The plugin to analyze
@param string            &$log   A string that hold logging detail
@param SimpleXMLExtended $xml    If specified, used this instead of the plugin's xml file

@return void
Add all the CMS nav items from the plugin