本文整理汇总了PHP中Knp\Menu\ItemInterface::setExtra方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemInterface::setExtra方法的具体用法?PHP ItemInterface::setExtra怎么用?PHP ItemInterface::setExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Knp\Menu\ItemInterface
的用法示例。
在下文中一共展示了ItemInterface::setExtra方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildExtras
/**
* Configures the newly created item's extras
* Extras are processed one by one in order not to reset values set by other extensions
*
* @param ItemInterface $item
* @param array $options
*/
private function buildExtras(ItemInterface $item, array $options)
{
if (!empty($options['extras'])) {
foreach ($options['extras'] as $key => $value) {
$item->setExtra($key, $value);
}
}
}
示例2: decorate
public function decorate(KnpMenuItem $knpMenuItem, AdminMenuItem $adminMenuItem)
{
if ($adminMenuItem instanceof RoutableItem && $adminMenuItem->getRoute()) {
$knpMenuItem->setUri($this->router->generate($adminMenuItem->getRoute(), $adminMenuItem->getRouteParameters()));
$routes = $knpMenuItem->getExtra('routes', array());
$routes[] = array('route' => $adminMenuItem->getRoute(), 'parameters' => $adminMenuItem->getRouteParameters());
$knpMenuItem->setExtra('routes', $routes);
}
}
示例3: addNavLinkRoute
protected function addNavLinkRoute(ItemInterface $menu, $label, $route, $routeParameters = array())
{
$item = $menu->addChild($label, array('route' => $route, 'routeParameters' => $routeParameters));
$item->setExtra('translation_domain', $menu->getExtra('translation_domain'));
$menu->setExtra('request_uri', $menu->getExtra('request_uri'));
if ($item->getUri() == $menu->getExtra('request_uri')) {
$item->setAttribute('class', 'active');
}
return $item;
}
示例4: decorate
public function decorate(KnpMenuItem $knpMenuItem, AdminMenuItem $adminMenuItem)
{
if ($adminMenuItem instanceof ElementItem && $adminMenuItem->hasOption('elements')) {
$routes = $knpMenuItem->getExtra('routes', array());
/** @var Element $element */
foreach ($adminMenuItem->getOption('elements') as $element) {
$routes[] = array('route' => $element->getRoute(), 'parameters' => $element->getRouteParameters());
}
$knpMenuItem->setExtra('routes', $routes);
}
}
示例5: buildItem
/**
* Build an item based on options
* @param ItemInterface $item
* @param array $options
*/
public function buildItem(ItemInterface $item, array $options)
{
if ($options['navbar']) {
$item->setChildrenAttribute('class', 'nav navbar-nav');
}
if ($options['pills']) {
$item->setChildrenAttribute('class', 'nav nav-pills');
}
if ($options['stacked']) {
$class = $item->getChildrenAttribute('class');
$item->setChildrenAttribute('class', $class . ' nav-stacked');
}
if ($options['dropdown-header']) {
$item->setAttribute('role', 'presentation')->setAttribute('class', 'dropdown-header')->setUri(null);
}
if ($options['list-group']) {
//echo "BLUBBB";
$item->setChildrenAttribute('class', 'list-group');
$item->setAttribute('class', 'list-group-item');
}
//var_dump($item->getLabel(), $item->getChildrenAttributes());
if ($options['list-group-item']) {
$item->setAttribute('class', 'list-group-item');
}
if ($options['dropdown']) {
$item->setUri('#')->setAttribute('class', 'dropdown')->setLinkAttribute('class', 'dropdown-toggle')->setLinkAttribute('data-toggle', 'dropdown')->setChildrenAttribute('class', 'dropdown-menu')->setChildrenAttribute('role', 'menu');
if ($options['caret']) {
$item->setExtra('caret', 'true');
}
}
if ($options['divider']) {
$item->setLabel('')->setUri(null)->setAttribute('role', 'presentation')->setAttribute('class', 'divider');
}
if ($options['pull-right']) {
$class = $item->getChildrenAttribute('class', '');
$item->setChildrenAttribute('class', $class . ' pull-right');
}
if ($options['icon']) {
$item->setExtra('icon', $options['icon']);
}
}
示例6: build
/**
* Modify menu by adding, removing or editing items.
*
* @param \Knp\Menu\ItemInterface $menu
* @param array $options
* @param string|null $alias
*/
public function build(ItemInterface $menu, array $options = [], $alias = null)
{
$user = $this->tokenStorage->getToken()->getUser();
$menu->setExtra('type', $alias);
if (is_object($user)) {
/** @var $entity NavigationItemInterface */
$entity = $this->factory->createItem($alias, []);
/** @var $repo NavigationRepositoryInterface */
$repo = $this->em->getRepository(get_class($entity));
$items = $repo->getNavigationItems($user->getId(), $alias, $options);
foreach ($items as $item) {
$menu->addChild($alias . '_item_' . $item['id'], ['extras' => $item, 'uri' => $item['url'], 'label' => $item['title']]);
}
}
}
示例7: build
/**
* Modify menu by adding, removing or editing items.
*
* @param \Knp\Menu\ItemInterface $menu
* @param array $options
* @param string|null $alias
*/
public function build(ItemInterface $menu, array $options = array(), $alias = null)
{
$user = $this->securityContext->getToken() ? $this->securityContext->getToken()->getUser() : null;
$menu->setExtra('type', $alias);
if (is_object($user)) {
$currentOrganization = $this->securityContext->getToken()->getOrganizationContext();
/** @var $entity NavigationItemInterface */
$entity = $this->factory->createItem($alias, array());
/** @var $repo NavigationRepositoryInterface */
$repo = $this->em->getRepository(ClassUtils::getClass($entity));
$items = $repo->getNavigationItems($user->getId(), $currentOrganization, $alias, $options);
foreach ($items as $item) {
$menu->addChild($alias . '_item_' . $item['id'], array('extras' => $item, 'uri' => $item['url'], 'label' => $item['title']));
}
}
}
示例8: build
public function build(ItemInterface $menu, array $options = array(), $alias = null)
{
$menu->setExtra('type', 'dropdown');
/* Disabled status menu till active stream will be implemented (BAP-617)
$menu->addChild(
'Update status',
array(
'route' => 'oro_user_status_create',
'attributes' => array(
'class' => 'update-status'
),
'linkAttributes' => array(
'class' => 'no-hash'
)
)
);*/
$menu->addChild('divider-' . rand(1, 99999))->setLabel('')->setAttribute('class', 'divider');
$menu->addChild('Logout', array('route' => 'oro_user_security_logout', 'linkAttributes' => array('class' => 'no-hash')));
}
示例9: createFromArray
/**
* @param ItemInterface $menu
* @param array $data
* @param array $itemList
* @param array $options
*
* @return \Knp\Menu\ItemInterface
*/
private function createFromArray(ItemInterface $menu, array $data, array &$itemList, array $options = array())
{
$isAllowed = false;
foreach ($data as $itemCode => $itemData) {
if (!empty($itemList[$itemCode])) {
$itemOptions = $itemList[$itemCode];
if (empty($itemOptions['name'])) {
$itemOptions['name'] = $itemCode;
}
if (empty($itemOptions['route']) && empty($itemOptions['uri'])) {
$itemOptions['route'] = $itemCode;
}
if (!empty($itemData['position'])) {
$itemOptions['extras']['position'] = $itemData['position'];
}
$this->moveToExtras($itemOptions, 'translateDomain');
$this->moveToExtras($itemOptions, 'translateParameters');
$newMenuItem = $menu->addChild($itemOptions['name'], array_merge($itemOptions, $options));
if (!empty($itemData['children'])) {
$this->createFromArray($newMenuItem, $itemData['children'], $itemList, $options);
}
$isAllowed = $isAllowed || $newMenuItem->getExtra('isAllowed');
}
}
$menu->setExtra('isAllowed', $isAllowed);
if ($menu->getExtra('hideIfEmpty') && $menu->hasChildren()) {
$willDisplaySomeChildren = false;
foreach ($menu->getChildren() as $child) {
if ($child->isDisplayed() && $child->getExtra('isAllowed')) {
$willDisplaySomeChildren = true;
break;
}
}
if (!$willDisplaySomeChildren) {
$menu->setDisplay(false);
}
}
}
示例10: createFromArray
/**
* @param ItemInterface $menu
* @param array $data
* @param array $itemList
* @param array $options
*
* @return \Knp\Menu\ItemInterface
*/
private function createFromArray(ItemInterface $menu, array $data, array &$itemList, array $options = array())
{
$isAllowed = false;
foreach ($data as $itemCode => $itemData) {
if (!empty($itemList[$itemCode])) {
$itemOptions = $itemList[$itemCode];
if (empty($itemOptions['name'])) {
$itemOptions['name'] = $itemCode;
}
if (!empty($itemData['position'])) {
$itemOptions['extras']['position'] = $itemData['position'];
}
$this->moveToExtras($itemOptions, 'translateDomain');
$this->moveToExtras($itemOptions, 'translateParameters');
$newMenuItem = $menu->addChild($itemOptions['name'], array_merge($itemOptions, $options));
if (!empty($itemData['children'])) {
$this->createFromArray($newMenuItem, $itemData['children'], $itemList, $options);
}
$isAllowed = $isAllowed || $newMenuItem->getExtra('isAllowed');
}
}
$menu->setExtra('isAllowed', $isAllowed);
}
示例11: build
public function build(ItemInterface $menu, array $options = [], $alias = null)
{
$menu->setExtra('type', 'dropdown');
$menu->addChild('divider-' . rand(1, 99999))->setLabel('')->setAttribute('class', 'divider');
$menu->addChild('Logout', ['route' => 'oro_user_security_logout', 'check_access' => false, 'linkAttributes' => ['class' => 'no-hash']]);
}
示例12: build
/**
* {@inheritDoc}
*/
public function build(ItemInterface $menu, array $options = array(), $alias = null)
{
$menu->setExtra('type', 'dropdown');
$menu->addChild('divider-' . rand(1, 99999))->setLabel('')->setAttribute('class', 'divider');
$menu->addChild('orob2b.account.menu.account_user_logout.label', ['route' => 'orob2b_account_account_user_security_logout', 'linkAttributes' => ['class' => 'no-hash']]);
}