Final Class Yiisoft\View\Cache\DynamicContent
| Inheritance | Yiisoft\View\Cache\DynamicContent |
|---|
DynamicContent generates data for dynamic content that is used for cached content {@see CachedContent}.
Public 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
| 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: |
| $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;
}
Generates the dynamic content.
| public string content ( ) | ||
| return | string |
The generated dynamic content. |
|---|---|---|
public function content(): string
{
return ($this->contentGenerator)($this->parameters);
}
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;
}
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]]>";
}
Signup or Login in order to comment.