function CommandWithAttachedAssetsTrait::getRenderedContent
Same name in other branches
- 9 core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php \Drupal\Core\Ajax\CommandWithAttachedAssetsTrait::getRenderedContent()
- 8.9.x core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php \Drupal\Core\Ajax\CommandWithAttachedAssetsTrait::getRenderedContent()
- 11.x core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php \Drupal\Core\Ajax\CommandWithAttachedAssetsTrait::getRenderedContent()
Processes the content for output.
If content is a render array, it may contain attached assets to be processed.
Return value
string|\Drupal\Component\Render\MarkupInterface HTML rendered content.
9 calls to CommandWithAttachedAssetsTrait::getRenderedContent()
- AfterCommand::render in core/
lib/ Drupal/ Core/ Ajax/ AfterCommand.php - Implements Drupal\Core\Ajax\CommandInterface:render().
- AjaxTestCommandReturnPromise::render in core/
modules/ system/ tests/ modules/ ajax_test/ src/ Ajax/ AjaxTestCommandReturnPromise.php - Implements Drupal\Core\Ajax\CommandInterface:render().
- AppendCommand::render in core/
lib/ Drupal/ Core/ Ajax/ AppendCommand.php - Implements Drupal\Core\Ajax\CommandInterface:render().
- BeforeCommand::render in core/
lib/ Drupal/ Core/ Ajax/ BeforeCommand.php - Implements Drupal\Core\Ajax\CommandInterface:render().
- HtmlCommand::render in core/
lib/ Drupal/ Core/ Ajax/ HtmlCommand.php - Implements Drupal\Core\Ajax\CommandInterface:render().
File
-
core/
lib/ Drupal/ Core/ Ajax/ CommandWithAttachedAssetsTrait.php, line 30
Class
- CommandWithAttachedAssetsTrait
- Trait for Ajax commands that render content and attach assets.
Namespace
Drupal\Core\AjaxCode
protected function getRenderedContent() {
$this->attachedAssets = new AttachedAssets();
if (is_array($this->content)) {
if (!$this->content) {
return '';
}
$html = \Drupal::service('renderer')->renderRoot($this->content);
$this->attachedAssets = AttachedAssets::createFromRenderArray($this->content);
return $html;
}
else {
return $this->content;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.