0 follower

Final Class Yiisoft\View\Cache\DynamicContent

InheritanceYiisoft\View\Cache\DynamicContent

DynamicContent generates data for dynamic content that is used for cached content {@see CachedContent}.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\View\Cache\DynamicContent
content() Generates the dynamic content. Yiisoft\View\Cache\DynamicContent
id() Returns a unique identifier of the dynamic content. Yiisoft\View\Cache\DynamicContent
placeholder() Returns the placeholder of the dynamic content. Yiisoft\View\Cache\DynamicContent

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( string $id, callable $contentGenerator, array $parameters = [] )
$id string

The unique identifier of the dynamic content.

$contentGenerator callable

PHP callable with the signature: function (array $parameters = []): string;.

$parameters array

The parameters (name-value pairs) that will be passed in the $contentGenerator context.

                public function __construct(
    private readonly string $id,
    callable $contentGenerator,
    private readonly array $parameters = []
) {
    $this->contentGenerator = $contentGenerator;
}

            
content() public method

Generates the dynamic content.

public string content ( )
return string

The generated dynamic content.

                public function content(): string
{
    return ($this->contentGenerator)($this->parameters);
}

            
id() public method

Returns a unique identifier of the dynamic content.

public string id ( )
return string

The unique identifier of the dynamic content.

                public function id(): string
{
    return $this->id;
}

            
placeholder() public method

Returns the placeholder of the dynamic content.

public string placeholder ( )
return string

The placeholder of the dynamic content.

                public function placeholder(): string
{
    return "<![CDATA[YII-DYNAMIC-$this->id]]>";
}