W3cubDocs

/Drupal 8

protected function CommandWithAttachedAssetsTrait::getRenderedContent

protected 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.

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\Ajax

Code

protected function getRenderedContent() {
  $this->attachedAssets = new AttachedAssets();
  if (is_array($this->content)) {
    $html = \Drupal::service('renderer')->renderRoot($this->content);
    $this->attachedAssets = AttachedAssets::createFromRenderArray($this->content);
    return $html;
  }
  else {
    return $this->content;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Ajax!CommandWithAttachedAssetsTrait.php/function/CommandWithAttachedAssetsTrait::getRenderedContent/8.1.x