0 follower

Final Class Yiisoft\Html\Tag\Link

InheritanceYiisoft\Html\Tag\Link » Yiisoft\Html\Tag\Base\VoidTag » Yiisoft\Html\Tag\Base\Tag
ImplementsYiisoft\Html\NoEncodeStringableInterface

Protected Properties

Hide inherited properties

Property Type Description Defined By
$attributes array Yiisoft\Html\Tag\Base\Tag

Method Details

Hide inherited methods

__toString() public method
public string __toString ( )

                final public function __toString(): string
{
    return $this->render();
}

            
addAttributes() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::addAttributes()

Add a set of attributes to existing tag attributes.

Same named attributes are replaced.

public Yiisoft\Html\Tag\Link addAttributes ( array $attributes )
$attributes array

Name-value set of attributes.

                final public function addAttributes(array $attributes): static
{
    $new = clone $this;
    $new->attributes = array_merge($new->attributes, $attributes);
    return $new;
}

            
addClass() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::addClass()

Add one or more CSS classes to the tag.

public Yiisoft\Html\Tag\Link addClass ( \BackedEnum|string|null $class )
$class \BackedEnum|string|null

One or many CSS classes.

                final public function addClass(BackedEnum|string|null ...$class): static
{
    $new = clone $this;
    Html::addCssClass($new->attributes, $class);
    return $new;
}

            
addStyle() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::addStyle()

Add CSS styles to the tag.

See also Yiisoft\Html\Html::addCssStyle().

public Yiisoft\Html\Tag\Link addStyle ( string|string[] $style, boolean $overwrite true )
$style string|string[]

The new style string (e.g. 'width: 100px; height: 200px') or array (e.g. ['width' => '100px', 'height' => '200px']).

$overwrite boolean

Whether to overwrite existing CSS properties if the new style contain them too.

                final public function addStyle(array|string $style, bool $overwrite = true): static
{
    $new = clone $this;
    Html::addCssStyle($new->attributes, $style, $overwrite);
    return $new;
}

            
after() protected method
protected string after ( )

                protected function after(): string
{
    return '';
}

            
as() public method

public self as ( string|null $value )
$value string|null

                public function as(?string $value): self
{
    $new = clone $this;
    $new->attributes['as'] = $value;
    return $new;
}

            
attribute() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::attribute()

Set attribute value.

public Yiisoft\Html\Tag\Link attribute ( string $name, mixed $value )
$name string

Name of the attribute.

$value mixed

Value of the attribute.

                final public function attribute(string $name, mixed $value): static
{
    $new = clone $this;
    $new->attributes[$name] = $value;
    return $new;
}

            
attributes() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::attributes()

Replace attributes with a new set.

public Yiisoft\Html\Tag\Link attributes ( array $attributes )
$attributes array

Name-value set of attributes.

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

            
before() protected method
protected string before ( )

                protected function before(): string
{
    return '';
}

            
class() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::class()

Replace current tag CSS classes with a new set of classes.

public Yiisoft\Html\Tag\Link class ( \BackedEnum|string|null $class )
$class \BackedEnum|string|null

One or many CSS classes.

                final public function class(BackedEnum|string|null ...$class): static
{
    $new = clone $this;
    unset($new->attributes['class']);
    Html::addCssClass($new->attributes, $class);
    return $new;
}

            
crossOrigin() public method

public self crossOrigin ( string|null $value )
$value string|null

                public function crossOrigin(?string $value): self
{
    $new = clone $this;
    $new->attributes['crossorigin'] = $value;
    return $new;
}

            
getName() protected method

protected string getName ( )

                protected function getName(): string
{
    return 'link';
}

            
href() public method

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

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

            
id() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::id()

Set tag ID.

public Yiisoft\Html\Tag\Link id ( string|null $id )
$id string|null

Tag ID.

                final public function id(?string $id): static
{
    $new = clone $this;
    $new->attributes['id'] = $id;
    return $new;
}

            
preload() public method

public self preload ( string $url, string|null $as null )
$url string
$as string|null

                public function preload(string $url, ?string $as = null): self
{
    $new = clone $this;
    $new->attributes['rel'] = 'preload';
    $new->attributes['href'] = $url;
    if ($as !== null) {
        $new->attributes['as'] = $as;
    }
    return $new;
}

            
prepareAttributes() protected method
protected void prepareAttributes ( )

                protected function prepareAttributes(): void {}

            
rel() public method

public self rel ( string|null $rel )
$rel string|null

                public function rel(?string $rel): self
{
    $new = clone $this;
    $new->attributes['rel'] = $rel;
    return $new;
}

            
removeStyle() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::removeStyle()

Remove CSS styles from the tag.

See also Yiisoft\Html\Html::removeCssStyle().

public Yiisoft\Html\Tag\Link removeStyle ( string|string[] $properties )
$properties string|string[]

The CSS properties to be removed. You may use a string if you are removing a single property.

                final public function removeStyle(string|array $properties): static
{
    $new = clone $this;
    Html::removeCssStyle($new->attributes, $properties);
    return $new;
}

            
render() public method
public string render ( )

                final public function render(): string
{
    return $this->before() . $this->renderTag() . $this->after();
}

            
renderAttributes() protected method

Defined in: Yiisoft\Html\Tag\Base\Tag::renderAttributes()

Render the current tag attributes.

See also Yiisoft\Html\Html::renderTagAttributes().

protected string renderAttributes ( )

                final protected function renderAttributes(): string
{
    $this->prepareAttributes();
    return Html::renderTagAttributes($this->attributes);
}

            
renderTag() protected method
protected string renderTag ( )

                final protected function renderTag(): string
{
    return '<' . $this->getName() . $this->renderAttributes() . '>';
}

            
tag() public static method
public static Yiisoft\Html\Tag\Link tag ( )

                final public static function tag(): static
{
    return new static();
}

            
title() public method

public self title ( string|null $title )
$title string|null

                public function title(?string $title): self
{
    $new = clone $this;
    $new->attributes['title'] = $title;
    return $new;
}

            
toCssFile() public static method

public static self toCssFile ( string $url )
$url string

                public static function toCssFile(string $url): self
{
    $link = self::tag();
    $link->attributes['rel'] = 'stylesheet';
    $link->attributes['href'] = $url;
    return $link;
}

            
type() public method

public self type ( string|null $type )
$type string|null

                public function type(?string $type): self
{
    $new = clone $this;
    $new->attributes['type'] = $type;
    return $new;
}

            
unionAttributes() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::unionAttributes()

Union attributes with a new set.

public Yiisoft\Html\Tag\Link unionAttributes ( array $attributes )
$attributes array

Name-value set of attributes.

                final public function unionAttributes(array $attributes): static
{
    $new = clone $this;
    $new->attributes += $attributes;
    return $new;
}

            
url() public method

Alias for {@see href}

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

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