本文整理汇总了PHP中Knp\Menu\ItemInterface::getExtras方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemInterface::getExtras方法的具体用法?PHP ItemInterface::getExtras怎么用?PHP ItemInterface::getExtras使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Knp\Menu\ItemInterface
的用法示例。
在下文中一共展示了ItemInterface::getExtras方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifyItem
protected function modifyItem(ItemInterface $item, array $options)
{
$extras = $item->getExtras();
if (!isset($extras['is_granted'])) {
return;
}
if (!$this->auth->isGranted($extras['is_granted'])) {
$this->removeItem($item);
}
}
示例2: toArray
/**
* @param ItemInterface $item
* @param integer|null $depth the depth until which children should be exported (null means unlimited)
*
* @return array
*/
public function toArray(ItemInterface $item, $depth = null)
{
$array = array('name' => $item->getName(), 'label' => $item->getLabel(), 'uri' => $item->getUri(), 'attributes' => $item->getAttributes(), 'labelAttributes' => $item->getLabelAttributes(), 'linkAttributes' => $item->getLinkAttributes(), 'childrenAttributes' => $item->getChildrenAttributes(), 'extras' => $item->getExtras(), 'display' => $item->isDisplayed(), 'displayChildren' => $item->getDisplayChildren(), 'current' => $item->isCurrent());
// export the children as well, unless explicitly disabled
if (0 !== $depth) {
$childDepth = null === $depth ? null : $depth - 1;
$array['children'] = array();
foreach ($item->getChildren() as $key => $child) {
$array['children'][$key] = $this->toArray($child, $childDepth);
}
}
return $array;
}