當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。