Skip to content
PHP Ecosystem
Explore

BreadcrumbLink

API reference › Bootstrap 6 › item › BreadcrumbLink

final readonly classyii2\extensions\bootstrap6\item\BreadcrumbLink
Uses traitsItemTrait
Sourcesrc/item/BreadcrumbLink.php

Represents a Breadcrumbs item: a link of the trail, or the active item.

PropertyTypeDescriptionDefined by
$active readonly constructorbool|nullWhether the item is active, or null to make it active when $url is null. Default: null.BreadcrumbLink
$encode readonly constructorbool|nullWhether to HTML-encode $label, or null to use Breadcrumbs::$encodeLabels. Default: null.BreadcrumbLink
$label readonly constructorstring|StringableLabel of the .breadcrumb-link element.BreadcrumbLink
$options readonly constructorarray<array-key, mixed>HTML attributes of the .breadcrumb-link element. Default: [].BreadcrumbLink
$template readonly constructorstring|nullTemplate of the item, where {link} is replaced by the rendered link, or null to use the widget item templates. Default: null.BreadcrumbLink
$url readonly constructorarray<array-key, mixed>|string|nullURL processed by Url::to(), or null for no href. Default: null.BreadcrumbLink
MethodDescriptionDefined by
fromArray() staticCreates an item from the array configuration documented in Breadcrumbs::$links.BreadcrumbLink
to() staticCreates an item.BreadcrumbLink
withActive()Returns a copy with the given active state.BreadcrumbLink
withEncode()Returns a copy with the given encoding flag.BreadcrumbLink
withLabel()Returns a copy with the given label.BreadcrumbLink
withOptions()Returns a copy with the given link attributes.BreadcrumbLink
withTemplate()Returns a copy with the given template.BreadcrumbLink
withUrl()Returns a copy with the given URL.BreadcrumbLink
public static function fromArray(array<array-key, mixed> $config): self

Creates an item from the array configuration documented in Breadcrumbs::$links.

The active and encode keys, even null, make their value explicit; a url or template of another type is ignored; every other key becomes an attribute of the link.

Parameters

ParameterTypeDescription
$configarray<array-key, mixed>Item configuration.

Returns

self

Throws

public static function to(string|Stringable $label, array<array-key, mixed>|string|null $url = null): self

Creates an item.

Parameters

ParameterTypeDescription
$labelstring|StringableLink label.
$urlarray<array-key, mixed>|string|nullURL processed by Url::to(), or null for the active item.

Returns

self

public function withActive(bool|null $active): self

Returns a copy with the given active state.

Parameters

ParameterTypeDescription
$activebool|null

Returns

self

public function withEncode(bool|null $encode): self

Returns a copy with the given encoding flag.

Parameters

ParameterTypeDescription
$encodebool|null

Returns

self

public function withLabel(string|Stringable $label): self

Returns a copy with the given label.

Parameters

ParameterTypeDescription
$labelstring|Stringable

Returns

self

public function withOptions(array<array-key, mixed> $options): self

Returns a copy with the given link attributes.

Parameters

ParameterTypeDescription
$optionsarray<array-key, mixed>HTML attributes of the link.

Returns

self

public function withTemplate(string|null $template): self

Returns a copy with the given template.

Parameters

ParameterTypeDescription
$templatestring|null

Returns

self

public function withUrl(array<array-key, mixed>|string|null $url): self

Returns a copy with the given URL.

Parameters

ParameterTypeDescription
$urlarray<array-key, mixed>|string|nullURL processed by Url::to().

Returns

self