예제 #1
0
 public static function getData(Attributes $obj)
 {
     $data = '';
     foreach ((array) $obj->getData() as $name => $value) {
         $data = $data . 'data-' . $name . '="' . htmlspecialchars($value, \ENT_QUOTES, 'UTF-8') . '" ';
     }
     return $data;
 }
예제 #2
0
 public function getDropdownMenu()
 {
     /** @var DropdownMenu $dropdown_menu */
     $dropdown_menu = DropdownMenu::create();
     foreach ($this->getItems() as $item) {
         if ($item->getText() === DropdownMenu::DIVIDER) {
             $dropdown_menu->addDivider();
         } else {
             $url = $item instanceof ContentNavItem ? '#' . $item->getId() : $item->getUrl();
             $attributes = $item->getAttributes();
             if ($item instanceof ContentNavItem) {
                 if (!$attributes instanceof Attributes) {
                     $attributes = Attributes::create();
                 }
                 $attributes->addData('toggle', 'tab');
             }
             $dropdown_menu->addLink($item->getText(), $url, false, $item->getDisabled(), false, $attributes);
         }
     }
     return $dropdown_menu;
 }