当前位置: 首页>>代码示例>>PHP>>正文


PHP ItemInterface::setExtra方法代码示例

本文整理汇总了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);
         }
     }
 }
开发者ID:andrewkrug,项目名称:repucaution,代码行数:15,代码来源:CoreExtension.php

示例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);
     }
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:9,代码来源:ItemRouteDecorator.php

示例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;
 }
开发者ID:ronzalo,项目名称:dyl_s2,代码行数:10,代码来源:Menu.php

示例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);
     }
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:11,代码来源:ItemElementsDecorator.php

示例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']);
     }
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:46,代码来源:MenuExtension.php

示例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']]);
         }
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:22,代码来源:NavigationItemBuilder.php

示例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']));
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:23,代码来源:NavigationItemBuilder.php

示例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')));
 }
开发者ID:Maksold,项目名称:platform,代码行数:19,代码来源:UserMenuBuilder.php

示例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);
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:46,代码来源:ConfigurationBuilder.php

示例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);
 }
开发者ID:xamin123,项目名称:platform,代码行数:31,代码来源:ConfigurationBuilder.php

示例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']]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:6,代码来源:UserMenuBuilder.php

示例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']]);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:9,代码来源:AccountUserMenuBuilder.php


注:本文中的Knp\Menu\ItemInterface::setExtra方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。