DynamicContentAwareTrait
API reference › yii › base › DynamicContentAwareTrait
Used by 2 types
DynamicContentAwareTrait implements common methods for classes
which support a View dynamic content feature.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
addDynamicPlaceholder() | Adds a placeholder for dynamic content. | DynamicContentAwareTrait |
getDynamicPlaceholders() | Returns a list of placeholders for dynamic content. This method is used internally to implement the content caching feature. | DynamicContentAwareTrait |
setDynamicPlaceholders() | Sets a list of placeholders for dynamic content. This method is used internally to implement the content caching feature. | DynamicContentAwareTrait |
getView() protected abstract | Returns the view object that can be used to render views or view files using dynamic contents. | DynamicContentAwareTrait |
updateDynamicContent() protected | Replaces placeholders in $content with results of evaluated dynamic statements. | DynamicContentAwareTrait |
Method details
Section titled “Method details”addDynamicPlaceholder()
Section titled “addDynamicPlaceholder() ”public function addDynamicPlaceholder(mixed $name, mixed $statements): mixedAdds a placeholder for dynamic content.
This method is used internally to implement the content caching feature.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | mixed | The placeholder name. |
$statements | mixed | The PHP statements for generating the dynamic content. |
Returns
mixed
getDynamicPlaceholders()
Section titled “getDynamicPlaceholders() ”public function getDynamicPlaceholders(): arrayReturns a list of placeholders for dynamic content. This method is used internally to implement the content caching feature.
Returns
array: A list of placeholders.
setDynamicPlaceholders()
Section titled “setDynamicPlaceholders() ”public function setDynamicPlaceholders(mixed $placeholders): mixedSets a list of placeholders for dynamic content. This method is used internally to implement the content caching feature.
Parameters
| Parameter | Type | Description |
|---|---|---|
$placeholders | mixed | A list of placeholders. |
Returns
mixed
getView()
Section titled “getView() ”abstract protected function getView(): yii\base\ViewReturns the view object that can be used to render views or view files using dynamic contents.
Returns
View: The view object that can be used to render views or view files.
updateDynamicContent()
Section titled “updateDynamicContent() ”protected function updateDynamicContent(string $content, string[] $placeholders, bool $isRestoredFromCache = false): stringReplaces placeholders in $content with results of evaluated dynamic statements.
Parameters
| Parameter | Type | Description |
|---|---|---|
$content | string | Content to be parsed. |
$placeholders | string[] | Placeholders and their values. |
$isRestoredFromCache | bool | Whether content is going to be restored from cache. |
Returns
string: Final content.