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 self active ( boolean $enabled )
$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 self attributes ( array $attributes )
$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 self encodeLabel ( boolean $enabled )
$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 array getAttributes ( )
return array

The HTML attributes for the link.

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

            
getLabel() public method

public string getLabel ( )
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 string|null getUrl ( )
return string|null

The URL for the link.

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

            
isActive() public method

public boolean isActive ( )
return boolean

Whether the item is active.

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

            
label() public method

Sets the label text to display.

public self label ( string $label )
$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 {@see BreadcrumbLink} instance.

public static self to ( string $label, string|null $url null, boolean $active false, array $attributes = [], boolean $encodeLabel true )
$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|null $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 self url ( string|null $url )
$url string|null

The URL for the link.

return self

A new instance with the specified URL.

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