示例#1
0
 /**
  * Get the evaluated contents of the object.
  *
  * @return string
  */
 public function render()
 {
     $output = '';
     foreach ($this->entries as $entry) {
         $entryAttributes = [];
         if ($entry instanceof DropdownDivider) {
             $entryAttributes['role'] = 'seperator';
             $entryAttributes['class'] = 'divider';
         } else {
             if ($entry instanceof DropdownHeader) {
                 $entryAttributes['class'] = 'dropdown-header';
             } else {
                 if (MenuHelper::isCurrentRoute($entry->getName())) {
                     $entryAttributes['class'] = 'active';
                 } else {
                     foreach ($entry->getAdditionalRouteNames() as $additionalRouteName) {
                         if (MenuHelper::isCurrentRoute($additionalRouteName)) {
                             $entryAttributes['class'] = ' active';
                         }
                     }
                 }
             }
         }
         $output .= '<li ' . Html::attributes($entryAttributes) . '>' . $entry->render() . '</li>';
     }
     if (empty($this->name)) {
         $link = Html::link('#', $this->title . '<span class="caret"></span>', ['class' => 'dropdown-toggle', 'data-toggle' => 'dropdown']);
     } else {
         $link = Html::linkRoute($this->name, $this->title . '<span class="caret"></span>', $this->parameters, ['class' => 'dropdown-toggle', 'data-toggle' => 'dropdown']);
     }
     return $link . '<ul class="dropdown-menu">' . $output . '</ul>';
 }
示例#2
0
 /**
  * Get the evaluated contents of the object.
  *
  * @return string
  */
 public function render()
 {
     if (empty($this->name)) {
         $content = Html::link('#', $this->title, $this->attributes);
     } else {
         $content = Html::linkRoute($this->name, $this->title, $this->parameters, $this->attributes);
     }
     return $content;
 }