本文整理汇总了PHP中Zend_Navigation_Page::setOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Navigation_Page::setOrder方法的具体用法?PHP Zend_Navigation_Page::setOrder怎么用?PHP Zend_Navigation_Page::setOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Navigation_Page
的用法示例。
在下文中一共展示了Zend_Navigation_Page::setOrder方法的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);
}
}