本文整理匯總了PHP中Zend\Navigation\Page\AbstractPage::getParent方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractPage::getParent方法的具體用法?PHP AbstractPage::getParent怎麽用?PHP AbstractPage::getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Navigation\Page\AbstractPage
的用法示例。
在下文中一共展示了AbstractPage::getParent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: accept
/**
* Determines whether a page should be accepted when iterating
*
* Default listener may be 'overridden' by attaching listener to 'isAllowed'
* method. Listener must be 'short circuited' if overriding default ACL
* listener.
*
* Rules:
* - If a page is not visible it is not accepted, unless RenderInvisible has
* been set to true
* - If $useAcl is true (default is true):
* - Page is accepted if listener returns true, otherwise false
* - If page is accepted and $recursive is true, the page
* will not be accepted if it is the descendant of a non-accepted page
*
* @param AbstractPage $page page to check
* @param bool $recursive [optional] if true, page will not be
* accepted if it is the descendant of
* a page that is not accepted. Default
* is true
*
* @return bool Whether page should be accepted
*/
public function accept(AbstractPage $page, $recursive = true)
{
$accept = true;
if (!$page->isVisible(false) && !$this->getRenderInvisible()) {
$accept = false;
} elseif ($this->getUseAcl()) {
$acl = $this->getAcl();
$role = $this->getRole();
$params = ['acl' => $acl, 'page' => $page, 'role' => $role];
$accept = $this->isAllowed($params);
}
if ($accept && $recursive) {
$parent = $page->getParent();
if ($parent instanceof AbstractPage) {
$accept = $this->accept($parent, true);
}
}
return $accept;
}
示例2: findRoot
/**
* Returns the root container of the given page
*
* When rendering a container, the render method still store the given
* container as the root container, and unset it when done rendering. This
* makes sure finder methods will not traverse above the container given
* to the render method.
*
* @param AbstractPage $page
* @return AbstractContainer
*/
protected function findRoot(AbstractPage $page)
{
if ($this->root) {
return $this->root;
}
$root = $page;
while ($parent = $page->getParent()) {
$root = $parent;
if ($parent instanceof AbstractPage) {
$page = $parent;
} else {
break;
}
}
return $root;
}