本文整理汇总了PHP中Zend\Navigation\Page\AbstractPage::isVisible方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPage::isVisible方法的具体用法?PHP AbstractPage::isVisible怎么用?PHP AbstractPage::isVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Navigation\Page\AbstractPage
的用法示例。
在下文中一共展示了AbstractPage::isVisible方法的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: accept
/**
* Determines whether a page should be accepted when iterating
*
* Rules:
* - If a page is not visible it is not accepted, unless RenderInvisible has
* been set to true.
* - If helper has no ACL, page is accepted
* - If helper has ACL, but no role, page is not accepted
* - If helper has ACL and role:
* - Page is accepted if it has no resource or privilege
* - Page is accepted if ACL allows page's resource or privilege
* - If page is accepted by the rules above 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 by default
$accept = true;
if (!$page->isVisible(false) && !$this->getRenderInvisible()) {
// don't accept invisible pages
$accept = false;
} elseif ($this->getUseAcl() && !$this->acceptAcl($page)) {
// acl is not amused
$accept = false;
}
if ($accept && $recursive) {
$parent = $page->getParent();
if ($parent instanceof AbstractPage) {
$accept = $this->accept($parent, true);
}
}
return $accept;
}