Same filename and directory in other branches
- 8.9.x core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php
- 9 core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php
Namespace
Drupal\Core\Ajax
File
core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php
View source
<?php
namespace Drupal\Core\Ajax;
use Drupal\Core\Asset\AttachedAssets;
trait CommandWithAttachedAssetsTrait {
protected $attachedAssets;
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;
}
}
public function getAttachedAssets() {
return $this->attachedAssets;
}
}
Traits