当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Navigation_Page::removePages方法代码示例

本文整理汇总了PHP中Zend_Navigation_Page::removePages方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Navigation_Page::removePages方法的具体用法?PHP Zend_Navigation_Page::removePages怎么用?PHP Zend_Navigation_Page::removePages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Navigation_Page的用法示例。


在下文中一共展示了Zend_Navigation_Page::removePages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mergePage

 /**
  * Merges a page (and its subpages) into this navigation.
  * If the page already exists in the navigation, then it attempts to add 
  * any new subpages of the page to it.  If a subpages already exists in the navigation, then it 
  * it recursively attempts to add its new subpages to it, and so on. 
  * 
  * @param  Zend_Navigation_Page $page  page to be merged
  * @return Zend_Navigation_Container  $parentContainer the suggested parentContainer for the page.
  * The parentContainer must already be in the navigation and remain so throughout the merge.                     
  * @throws Zend_Navigation_Exception    if a subpage is invalid
  * @throws RuntimeException     if the page or parentContainer is invalid  
  */
 public function mergePage(Zend_Navigation_Page $page, Zend_Navigation_Container $parentContainer = null)
 {
     if (!$page->uid) {
         // we assume that every page has already been normalized
         throw new RuntimeException(__('The page must be normalized and have a valid uid.'));
     }
     if ($parentContainer === null) {
         $parentContainer = $this;
     }
     // save the child pages and remove them from the current page
     $childPages = $page->getPages();
     $page->removePages($childPages);
     if (!($oldPage = $this->getPageByUid($page->uid))) {
         if ($parentContainer !== $this && !$this->hasPage($parentContainer, true)) {
             // we assume parentContainer is either the navigation object
             // or a descendant page of the navigation object
             throw RuntimeException(__('The parent container must either be the navigation object' . ' or a descendant subpage of the navigation object.'));
         }
         // add the page to the end of the parent container
         $pageOrder = $this->_getLastPageOrderInContainer($parentContainer) + 1;
         $page->setOrder($pageOrder);
         $this->addPageToContainer($page, $parentContainer);
         // set the new parent page
         $parentPage = $page;
     } else {
         // set the new parent page
         $parentPage = $oldPage;
     }
     // merge the child pages
     foreach ($childPages as $childPage) {
         $this->mergePage($childPage, $parentPage);
     }
 }
开发者ID:kwiliarty,项目名称:Omeka,代码行数:45,代码来源:Navigation.php


注:本文中的Zend_Navigation_Page::removePages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。