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


PHP ItemInterface::setAttribute方法代碼示例

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


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

示例1: setActive

 /**
  * Set active class to current item and all its parents (so it is automatically opened)
  * 
  * @param ItemInterface $item
  */
 protected function setActive(ItemInterface $item = null)
 {
     if ($item) {
         $this->setActive($item->getParent());
         $item->setAttribute('class', $item->getAttribute('class', '') . ' active');
     }
 }
開發者ID:hyperlator,項目名稱:GeneratorBundle,代碼行數:12,代碼來源:AdmingeneratorMenuBuilder.php

示例2: decorate

 public function decorate(KnpMenuItem $knpMenuItem, AdminMenuItem $adminMenuItem)
 {
     $knpMenuItem->setUri('#');
     if ($adminMenuItem->hasOption('attr')) {
         $knpMenuItem->setAttributes($adminMenuItem->getOption('attr'));
     }
     if ($adminMenuItem->hasChildren()) {
         $knpMenuItem->setAttribute('dropdown', true);
     }
 }
開發者ID:kbedn,項目名稱:admin-bundle,代碼行數:10,代碼來源:ItemAttributesDecorator.php

示例3: 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

示例4: putChildAttributes

 protected function putChildAttributes(ItemInterface $itemInterface)
 {
     $itemInterface->setAttribute("class", "sub-menu");
 }
開發者ID:skillberto,項目名稱:SonataPageMenuBundle,代碼行數:4,代碼來源:MainMenuBuilder.php

示例5: createMainDropdownMenuItem

 protected function createMainDropdownMenuItem(ItemInterface $rootItem, $title, $push_right = true, $icon = array(), $knp_item_options = array())
 {
     $rootItem->setAttribute('class', 'nav navbar-nav');
     if ($push_right) {
         $this->pushRight($rootItem);
     }
     $dropdown = $rootItem->addChild($title, array_merge(array('uri' => '#'), $knp_item_options))->setLinkattribute('class', 'dropdown-main-toggle')->setLinkattribute('data-toggle', 'dropdown')->setAttribute('class', 'dropdown-main')->setChildrenAttribute('class', 'dropdown-main-menu');
     // TODO: make XSS safe $icon contents escaping
     switch (true) {
         case isset($icon['icon']) || isset($icon['glyphicon']):
             $this->addIcon($dropdown, $icon);
             break;
         case isset($icon['caret']) && $icon['caret'] === true:
             $this->addCaret($dropdown, $icon);
     }
     return $dropdown;
 }
開發者ID:shakaran,項目名稱:powerline-server,代碼行數:17,代碼來源:MenuBuilder.php

示例6: pushRight

 protected function pushRight(ItemInterface $item)
 {
     $item->setAttribute('class', 'nav pull-right');
     return $item;
 }
開發者ID:rk3rn3r,項目名稱:MopaBootstrapBundle,代碼行數:5,代碼來源:AbstractNavbarMenuBuilder.php

示例7: addClass

 public function addClass(ItemInterface $menu)
 {
     $menu->setAttribute('class', sprintf('menu-icon-%s', $menu->getName()));
 }
開發者ID:npakai,項目名稱:enhavo,代碼行數:4,代碼來源:MenuEventListener.php


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