BreadcrumbLink
API reference › Bootstrap 6 › item › BreadcrumbLink
Represents a Breadcrumbs item: a link of the trail, or the active item.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$active readonly constructor | bool| | Whether the item is active, or null to make it active when $url is null. Default: null. | BreadcrumbLink |
$encode readonly constructor | bool| | Whether to HTML-encode $label, or null to use Breadcrumbs::$encodeLabels. Default: null. | BreadcrumbLink |
$label readonly constructor | string|Stringable | Label of the .breadcrumb-link element. | BreadcrumbLink |
$options readonly constructor | array<array-key, | HTML attributes of the .breadcrumb-link element. Default: []. | BreadcrumbLink |
$template readonly constructor | string| | Template of the item, where {link} is replaced by the rendered link, or null to use the widget item templates. Default: null. | BreadcrumbLink |
$url readonly constructor | array<array-key, | URL processed by Url::to(), or null for no href. Default: null. | BreadcrumbLink |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
fromArray() static | Creates an item from the array configuration documented in Breadcrumbs::$links. | BreadcrumbLink |
to() static | Creates 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 |
Method details
Section titled “Method details”fromArray()
Section titled “fromArray() ”public static function fromArray(array<array-key, mixed> $config): selfCreates 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
| Parameter | Type | Description |
|---|---|---|
$config | array<array-key, | Item configuration. |
Returns
self
Throws
yii\base\InvalidConfigException: if the item has nostring|Stringablelabel.
public static function to(string|Stringable $label, array<array-key, mixed>|string|null $url = null): selfCreates an item.
Parameters
| Parameter | Type | Description |
|---|---|---|
$label | string|Stringable | Link label. |
$url | array<array-key, | URL processed by Url::to(), or null for the active item. |
Returns
self
withActive()
Section titled “withActive() ”public function withActive(bool|null $active): selfReturns a copy with the given active state.
Parameters
| Parameter | Type | Description |
|---|---|---|
$active | bool| |
Returns
self
withEncode()
Section titled “withEncode() ”public function withEncode(bool|null $encode): selfReturns a copy with the given encoding flag.
Parameters
| Parameter | Type | Description |
|---|---|---|
$encode | bool| |
Returns
self
withLabel()
Section titled “withLabel() ”public function withLabel(string|Stringable $label): selfReturns a copy with the given label.
withOptions()
Section titled “withOptions() ”public function withOptions(array<array-key, mixed> $options): selfReturns a copy with the given link attributes.
Parameters
| Parameter | Type | Description |
|---|---|---|
$options | array<array-key, | HTML attributes of the link. |
Returns
self
withTemplate()
Section titled “withTemplate() ”public function withTemplate(string|null $template): selfReturns a copy with the given template.
Parameters
| Parameter | Type | Description |
|---|---|---|
$template | string| |
Returns
self
withUrl()
Section titled “withUrl() ”public function withUrl(array<array-key, mixed>|string|null $url): selfReturns a copy with the given URL.
Parameters
| Parameter | Type | Description |
|---|---|---|
$url | array<array-key, | URL processed by Url::to(). |
Returns
self