本文整理汇总了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');
}
}
示例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);
}
}
示例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']);
}
}
示例4: putChildAttributes
protected function putChildAttributes(ItemInterface $itemInterface)
{
$itemInterface->setAttribute("class", "sub-menu");
}
示例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;
}
示例6: pushRight
protected function pushRight(ItemInterface $item)
{
$item->setAttribute('class', 'nav pull-right');
return $item;
}
示例7: addClass
public function addClass(ItemInterface $menu)
{
$menu->setAttribute('class', sprintf('menu-icon-%s', $menu->getName()));
}