0 follower

Final Class Yiisoft\Yii\Bulma\Breadcrumbs

InheritanceYiisoft\Yii\Bulma\Breadcrumbs » Yiisoft\Widget\Widget

The Bulma breadcrumb is a simple navigation component.

echo Breadcrumbs::widget()->items([
    ['label' => 'Info'],
    ['label' => 'Contacts'],
]);

Public Methods

Hide inherited methods

Method Description Defined By
activeItemTemplate() Returns a new instance with the specified active item template. Yiisoft\Yii\Bulma\Breadcrumbs
ariaLabel() Returns a new instance with the specified aria-label attribute for the current element. Yiisoft\Yii\Bulma\Breadcrumbs
attributes() Returns a new instance with the specified HTML attributes for widget. Yiisoft\Yii\Bulma\Breadcrumbs
autoIdPrefix() Returns a new instance with the specified prefix to the automatically generated widget IDs. Yiisoft\Yii\Bulma\Breadcrumbs
encode() Returns a new instance with the specified whether the tags for the breadcrumbs are encoded. Yiisoft\Yii\Bulma\Breadcrumbs
homeItem() Returns a new instance with the specified first item in the breadcrumbs (called home link). Yiisoft\Yii\Bulma\Breadcrumbs
id() Returns a new instance with the specified ID of the widget. Yiisoft\Yii\Bulma\Breadcrumbs
itemTemplate() Returns a new instance with the specified item template. Yiisoft\Yii\Bulma\Breadcrumbs
items() Returns a new instance with the specified list of items. Yiisoft\Yii\Bulma\Breadcrumbs
itemsAttributes() Returns a new instance with the specified items HTML attributes. Yiisoft\Yii\Bulma\Breadcrumbs
render() Yiisoft\Yii\Bulma\Breadcrumbs

Method Details

Hide inherited methods

activeItemTemplate() public method

Returns a new instance with the specified active item template.

public self activeItemTemplate ( string $value )
$value string

The template used to render each active item in the breadcrumbs. The token {link} will be replaced with the actual HTML link for each active item.

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

            
ariaLabel() public method

Returns a new instance with the specified aria-label attribute for the current element.

public self ariaLabel ( string $value )
$value string

The value of the aria-label attribute.

                public function ariaLabel(string $value): self
{
    $new = clone $this;
    $new->attributes['aria-label'] = $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;
}

            
encode() public method

Returns a new instance with the specified whether the tags for the breadcrumbs are encoded.

public self encode ( boolean $value )
$value boolean

Whether to encode the output.

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

            
homeItem() public method

Returns a new instance with the specified first item in the breadcrumbs (called home link).

If a null is specified, the home item will not be rendered.

public self homeItem ( array|null $value )
$value array|null

Please refer to {@see \Yiisoft\Yii\Bulma\items()} on the format.

throws InvalidArgumentException

If an empty array is specified.

                public function homeItem(?array $value): self
{
    if ($value === []) {
        throw new InvalidArgumentException(
            'The home item cannot be an empty array. To disable rendering of the home item, specify null.',
        );
    }
    $new = clone $this;
    $new->homeItem = $value;
    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;
}

            
itemTemplate() public method

Returns a new instance with the specified item template.

public self itemTemplate ( string $value )
$value string

The template used to render each inactive item in the breadcrumbs. The token {link} will be replaced with the actual HTML link for each inactive item.

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

            
items() public method

Returns a new instance with the specified list of items.

public self items ( array $value )
$value array

List of items to appear in the breadcrumbs. If this property is empty, the widget will not render anything. Each array element represents a single item in the breadcrumbs with the following structure:

[
    'label' => 'label of the link', // required
    'url' => 'url of the link', // optional, will be processed by Url::to()
    'template' => 'own template of the item', // optional, if not set $this->itemTemplate will be used
    'encode' => true/false, // optional, is encoded is `true`, the tags will be encoded
    'icon' => 'icon css class', // optional, icon css class
    'iconAttributes' => [], // the html attributes for icon container
]

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

            
itemsAttributes() public method

Returns a new instance with the specified items HTML attributes.

public self itemsAttributes ( array $value )
$value array

The HTML attributes for the item's widget.

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

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

            
render() public method

public string render ( )

                public function render(): string
{
    if (empty($this->items)) {
        return '';
    }
    $attributes = $this->attributes;
    $customTag = CustomTag::name('nav');
    Html::addCssClass($attributes, 'breadcrumb');
    if (!array_key_exists('aria-label', $attributes)) {
        $customTag = $customTag->attribute('aria-label', 'breadcrumbs');
    }
    if (!array_key_exists('id', $attributes)) {
        $customTag = $customTag->id(Html::generateId($this->autoIdPrefix) . '-breadcrumbs');
    }
    $content = PHP_EOL . Html::openTag('ul', $this->itemsAttributes) . PHP_EOL .
        implode('', $this->renderItems()) .
        Html::closeTag('ul') . PHP_EOL;
    return $customTag
        ->addAttributes($attributes)
        ->content($content)
        ->encode(false)
        ->render();
}