0 follower

Final Class Yiisoft\Bootstrap5\BreadcrumbLink

InheritanceYiisoft\Bootstrap5\BreadcrumbLink

BreadcrumbLink represents a single breadcrumb navigation link.

Each link can be either active or inactive, and can be rendered as a plain text (when active) or as a hyperlink (when inactive).

Example: `php // Create a standard link BreadcrumbLink::to('Home', '/');

// Create an active link (current page) BreadcrumbLink::to('Current Page', null, true);

// Create a link with custom attributes BreadcrumbLink::to('Link', '/path', false, ['class' => 'custom-link']); `

Method Details

Hide inherited methods

active() public method

Sets the active state.

public active( boolean $enabled ): self
$enabled boolean

Whether the breadcrumb link is active.

return self

A new instance with the specified active state.

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

            
attributes() public method

Sets the HTML attributes for the link.

public attributes( array $attributes ): self
$attributes array

Attribute values indexed by attribute names.

return self

A new instance with the specified attributes.

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

            
encodeLabel() public method

Sets whether to HTML encode the label.

public encodeLabel( boolean $enabled ): self
$enabled boolean

Whether to HTML encode the label.

return self

A new instance with the specified encoding behavior.

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

            
getAttributes() public method

public getAttributes( ): array
return array

The HTML attributes for the link.

                public function getAttributes(): array
{
    return $this->attributes;
}

            
getLabel() public method

public getLabel( ): string
return string

The encoded label content. For default behavior, the label will be HTML-encoded. You can disable this by setting encodeLabel to false.

                public function getLabel(): string
{
    return $this->encodeLabel ? Html::encode($this->label) : $this->label;
}

            
getUrl() public method

public getUrl( ): string|null
return string|null

The URL for the link.

                public function getUrl(): ?string
{
    return $this->url;
}

            
isActive() public method

public isActive( ): boolean
return boolean

Whether the item is active.

                public function isActive(): bool
{
    return $this->active;
}

            
label() public method

Sets the label text to display.

public label( string $label ): self
$label string

The label text to display.

return self

A new instance with the specified label.

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

            
to() public static method

Creates a new Yiisoft\Bootstrap5\BreadcrumbLink instance.

public static to( string $label, string|null $url null, boolean $active false, array $attributes = [], boolean $encodeLabel true ): self
$label string

The label text to display.

$url string|null

The URL for the link.

$active boolean

Whether this link represents the current page.

$attributes array

Additional HTML attributes for the link.

$encodeLabel boolean

Whether to HTML encode the label.

return self

A new instance with the specified configuration.

                public static function to(
    string $label,
    ?string $url = null,
    bool $active = false,
    array $attributes = [],
    bool $encodeLabel = true,
): self {
    return new self($label, $url, $active, $encodeLabel, $attributes);
}

            
url() public method

Sets the URL for the link.

public url( string|null $url ): self
$url string|null

The URL for the link.

return self

A new instance with the specified URL.

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