當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ItemInterface::getPermissions方法代碼示例

本文整理匯總了PHP中Knp\Menu\ItemInterface::getPermissions方法的典型用法代碼示例。如果您正苦於以下問題:PHP ItemInterface::getPermissions方法的具體用法?PHP ItemInterface::getPermissions怎麽用?PHP ItemInterface::getPermissions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Knp\Menu\ItemInterface的用法示例。


在下文中一共展示了ItemInterface::getPermissions方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: renderItem

 protected function renderItem(ItemInterface $item, array $options)
 {
     if (!\App::isGranted($item->getPermissions())) {
         return '';
     }
     // if we don't have access or this item is marked to not be shown
     if (!$item->isDisplayed()) {
         return '';
     }
     // create an array than can be imploded as a class list
     $class = (array) $item->getAttribute('class');
     if ($this->matcher->isCurrent($item)) {
         $class[] = $options['currentClass'];
     } elseif ($this->matcher->isAncestor($item, $options['matchingDepth'])) {
         $class[] = $options['ancestorClass'];
     }
     if ($item->actsLikeFirst()) {
         $class[] = $options['firstClass'];
     }
     if ($item->actsLikeLast()) {
         $class[] = $options['lastClass'];
     }
     if ($item->hasChildren() && $options['depth'] !== 0) {
         if (null !== $options['branch_class'] && $item->getDisplayChildren()) {
             $class[] = $options['branch_class'];
         }
     } elseif (null !== $options['leaf_class']) {
         $class[] = $options['leaf_class'];
     }
     // retrieve the attributes and put the final class string back on it
     $attributes = $item->getAttributes();
     if (!empty($class)) {
         $attributes['class'] = implode(' ', $class);
     }
     // opening li tag
     $html = $this->format('<li' . $this->renderHtmlAttributes($attributes) . '>', 'li', $item->getLevel(), $options);
     // render the text/link inside the li tag
     //$html .= $this->format($item->getUri() ? $item->renderLink() : $item->renderLabel(), 'link', $item->getLevel());
     $html .= $this->renderLink($item, $options);
     // renders the embedded ul
     $childrenClass = (array) $item->getChildrenAttribute('class');
     // $childrenClass[] = 'menu_level_'.$item->getLevel();
     $childrenAttributes = $item->getChildrenAttributes();
     // has been set implocitly here, can use ->setChildrenAttributes(array('class'=> 'treeview-menu')) while menu creating
     $childrenAttributes['class'] = 'treeview-menu';
     $childrenAttributes['class'] .= implode(' ', $childrenClass);
     $html .= $this->renderList($item, $childrenAttributes, $options);
     // closing li tag
     $html .= $this->format('</li>', 'li', $item->getLevel(), $options);
     return $html;
 }
開發者ID:santhapa,項目名稱:ci-mag-cms,代碼行數:51,代碼來源:MenuRenderer.php


注:本文中的Knp\Menu\ItemInterface::getPermissions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。