0 follower

Final Class Yiisoft\Yii\Bulma\Menu

InheritanceYiisoft\Yii\Bulma\Menu » Yiisoft\Widget\Widget

The Bulma menu is a vertical navigation component.

Public Methods

Hide inherited methods

Method Description Defined By
activateParents() Returns a new instance with the activated parent items. Yiisoft\Yii\Bulma\Menu
activeCssClass() Returns a new instance with the specified active CSS class. Yiisoft\Yii\Bulma\Menu
attributes() Returns a new instance with the specified HTML attributes for widget. Yiisoft\Yii\Bulma\Menu
autoIdPrefix() Returns a new instance with the specified prefix to the automatically generated widget IDs. Yiisoft\Yii\Bulma\Menu
brand() Returns a new instance with the specified HTML code of brand. Yiisoft\Yii\Bulma\Menu
currentPath() Returns a new instance with the specified current path. Yiisoft\Yii\Bulma\Menu
deactivateItems() Returns a new instance with the specified disables active items according to their current path. Yiisoft\Yii\Bulma\Menu
firstItemCssClass() Returns a new instance with the specified first item CSS class. Yiisoft\Yii\Bulma\Menu
hiddenEmptyItems() Returns a new instance with the specified hidden empty items. Yiisoft\Yii\Bulma\Menu
id() Returns a new instance with the specified ID of the widget. Yiisoft\Yii\Bulma\Menu
itemAttributes() Returns a new instance with the specified item attributes. Yiisoft\Yii\Bulma\Menu
items() Returns a new instance with the specified items. Yiisoft\Yii\Bulma\Menu
itemsTag() Return a new instance with tag for item container. Yiisoft\Yii\Bulma\Menu
labelTemplate() Returns a new instance with the specified label template. Yiisoft\Yii\Bulma\Menu
lastItemCssClass() Returns a new instance with the specified last item CSS class. Yiisoft\Yii\Bulma\Menu
render() Renders the menu. Yiisoft\Yii\Bulma\Menu
urlTemplate() Returns a new instance with the specified link template. Yiisoft\Yii\Bulma\Menu

Method Details

Hide inherited methods

activateParents() public method

Returns a new instance with the activated parent items.

Activates parent menu items when one of the corresponding child menu items is active. The activated parent menu items will also have its CSS classes appended with {@see \Yiisoft\Yii\Bulma\activeCssClass()}.

public self activateParents ( )

                public function activateParents(): self
{
    $new = clone $this;
    $new->activateParents = true;
    return $new;
}

            
activeCssClass() public method

Returns a new instance with the specified active CSS class.

public self activeCssClass ( string $value )
$value string

The CSS class to be appended to the active menu item.

                public function activeCssClass(string $value): self
{
    $new = clone $this;
    $new->activeCssClass = $value;
    return $new;
}

            
attributes() public method

Returns a new instance with the specified HTML attributes for widget.

public self attributes ( array $values )
$values array

Attribute values indexed by attribute names.

{@see \Yiisoft\Html\Html::renderTagAttributes()} For details on how attributes are being rendered.

                public function attributes(array $values): self
{
    $new = clone $this;
    $new->attributes = $values;
    return $new;
}

            
autoIdPrefix() public method

Returns a new instance with the specified prefix to the automatically generated widget IDs.

public self autoIdPrefix ( string $value )
$value string

The prefix to the automatically generated widget IDs.

                public function autoIdPrefix(string $value): self
{
    $new = clone $this;
    $new->autoIdPrefix = $value;
    return $new;
}

            
brand() public method

Returns a new instance with the specified HTML code of brand.

public self brand ( string $value )
$value string

The HTML code of brand.

                public function brand(string $value): self
{
    $new = clone $this;
    $new->brand = $value;
    return $new;
}

            
currentPath() public method

Returns a new instance with the specified current path.

public self currentPath ( string $value )
$value string

The current path.

                public function currentPath(string $value): self
{
    $new = clone $this;
    $new->currentPath = $value;
    return $new;
}

            
deactivateItems() public method

Returns a new instance with the specified disables active items according to their current path.

{@see \Yiisoft\Yii\Bulma\isItemActive}

public self deactivateItems ( )

                public function deactivateItems(): self
{
    $new = clone $this;
    $new->activateItems = false;
    return $new;
}

            
firstItemCssClass() public method

Returns a new instance with the specified first item CSS class.

public self firstItemCssClass ( string $value )
$value string

The CSS class that will be assigned to the first item in the main menu or each submenu.

                public function firstItemCssClass(string $value): self
{
    $new = clone $this;
    $new->firstItemCssClass = $value;
    return $new;
}

            
hiddenEmptyItems() public method

Returns a new instance with the specified hidden empty items.

public self hiddenEmptyItems ( )

                public function hiddenEmptyItems(): self
{
    $new = clone $this;
    $new->hiddenEmptyItems = true;
    return $new;
}

            
id() public method

Returns a new instance with the specified ID of the widget.

public self id ( string $value )
$value string

The ID of the widget.

                public function id(string $value): self
{
    $new = clone $this;
    $new->attributes['id'] = $value;
    return $new;
}

            
itemAttributes() public method

Returns a new instance with the specified item attributes.

public self itemAttributes ( array $value )
$value array

List of HTML attributes shared by all menu {@see \Yiisoft\Yii\Bulma\items}. If any individual menu item specifies its attributes, it will be merged with this property before being used to generate the HTML attributes for the menu item tag. The following special attributes are recognized:

{@see \Yiisoft\Html\Html::renderTagAttributes() For details on how attributes are being rendered}

                public function itemAttributes(array $value): self
{
    $new = clone $this;
    $new->itemAttributes = $value;
    return $new;
}

            
items() public method

Returns a new instance with the specified items.

public self items ( array $value )
$value array

List of menu items. Each menu item should be an array of the following structure:

  • label: string, optional, specifies the menu item label. When {@see \Yiisoft\Yii\Bulma\encode} is true, the label will be HTML-encoded. If the label is not specified, an empty string will be used.
  • encode: bool, optional, whether this item`s label should be HTML-encoded. This param will override global {@see \Yiisoft\Yii\Bulma\encode} param.
  • url: string or array, optional, specifies the URL of the menu item. When this is set, the actual menu item content will be generated using {@see \Yiisoft\Yii\Bulma\urlTemplate}; otherwise, {@see \Yiisoft\Yii\Bulma\labelTemplate} will be used.
  • visible: bool, optional, whether this menu item is visible. Defaults to true.
  • items: array, optional, specifies the sub-menu items. Its format is the same as the parent items.
  • active: bool or Closure, optional, whether this menu item is in active state (currently selected). When using a closure, its signature should be function ($item, $hasActiveChild, $isItemActive, $Widget). Closure must return true if item should be marked as active, otherwise - false. If a menu item is active, its CSS class will be appended with {@see \Yiisoft\Yii\Bulma\activeCssClass}. If this option is not set, the menu item will be set active automatically when the current request is triggered by url. For more details, please refer to {@see \Yiisoft\Yii\Bulma\isItemActive()}.
  • labelTemplate: string, optional, the template used to render the content of this menu item. The token {label} will be replaced by the label of the menu item. If this option is not set, {@see \Yiisoft\Yii\Bulma\labelTemplate} will be used instead.
  • urlTemplate: string, optional, the template used to render the content of this menu item. The token {url} will be replaced by the URL associated with this menu item. If this option is not set, {@see \Yiisoft\Yii\Bulma\urlTemplate} will be used instead.
  • subMenuTemplate: string, optional, the template used to render the list of sub-menus. The token {items} will be replaced with the rendered sub-menu items. If this option is not set, {@see \Yiisoft\Yii\Bulma\subMenuTemplate} will be used instead.
  • itemAttributes: array, optional, the HTML attributes for the item container tag.
  • icon: string, optional, class icon.
  • iconAttributes: array, optional, the HTML attributes for the container icon.

                public function items(array $value): self
{
    $new = clone $this;
    $new->items = $value;
    return $new;
}

            
itemsTag() public method

Return a new instance with tag for item container.

public self itemsTag ( string|null $value )
$value string|null

The tag for item container, null value means that container tag will not be rendered.

                public function itemsTag(?string $value): self
{
    if ($value === '') {
        throw new InvalidArgumentException('Tag for item container cannot be empty.');
    }
    $new = clone $this;
    $new->itemsTag = $value;
    return $new;
}

            
labelTemplate() public method

Returns a new instance with the specified label template.

public self labelTemplate ( string $value )
$value string

The template used to render the body of a menu which is NOT a link.

In this template, the token {label} will be replaced with the label of the menu item.

This property will be overridden by the template option set in individual menu items via {@see \Yiisoft\Yii\Bulma\items}.

                public function labelTemplate(string $value): self
{
    $new = clone $this;
    $new->labelTemplate = $value;
    return $new;
}

            
lastItemCssClass() public method

Returns a new instance with the specified last item CSS class.

public self lastItemCssClass ( string $value )
$value string

The CSS class that will be assigned to the last item in the main menu or each submenu.

                public function lastItemCssClass(string $value): self
{
    $new = clone $this;
    $new->lastItemCssClass = $value;
    return $new;
}

            
render() public method

Renders the menu.

public string render ( )
return string

The result of Widget execution to be outputted.

throws JsonException

                public function render(): string
{
    $items = $this->normalizeItems($this->items);
    if (empty($items)) {
        return '';
    }
    return $this->renderMenu($items);
}

            
urlTemplate() public method

Returns a new instance with the specified link template.

public self urlTemplate ( string $value )
$value string

The template used to render the body of a menu which is a link. In this template, the token {url} will be replaced with the corresponding link URL; while {label} will be replaced with the link text.

This property will be overridden by the template option set in individual menu items via {@see \Yiisoft\Yii\Bulma\items}.

                public function urlTemplate(string $value): self
{
    $new = clone $this;
    $new->urlTemplate = $value;
    return $new;
}