You are here

class AddAssetsCommand in Content-Security-Policy 8

AJAX command for including additional assets.

The 'add_assets' command instructs the client to load additional JS and CSS.

This command is implemented by Drupal.AjaxCommands.prototype.add_assets() defined in csp_extras/js/ajax.js.

Hierarchy

Expanded class hierarchy of AddAssetsCommand

File

csp_extras/src/Ajax/AddAssetsCommand.php, line 17

Namespace

Drupal\csp_extras\Ajax
View source
class AddAssetsCommand implements CommandInterface {

  /**
   * An array of assets keyed by their type (either 'script' or 'style').
   *
   * @var array[]
   */
  protected $assets;

  /**
   * Constructs a AddAssetsCommand object.
   *
   * @param array[] $assets
   *   An array of asset element definitions.
   */
  public function __construct(array $assets) {
    $this->assets = array_values($assets);
  }

  /**
   * Implements Drupal\Core\Ajax\CommandInterface:render().
   */
  public function render() {
    return [
      'command' => 'add_assets',
      'assets' => $this->assets,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AddAssetsCommand::$assets protected property An array of assets keyed by their type (either 'script' or 'style').
AddAssetsCommand::render public function Implements Drupal\Core\Ajax\CommandInterface:render(). Overrides CommandInterface::render
AddAssetsCommand::__construct public function Constructs a AddAssetsCommand object.