You are here

class EmbedInsertCommand in Embed 8

AJAX command for inserting an embedded item in an editor.

Hierarchy

Expanded class hierarchy of EmbedInsertCommand

1 file declares its use of EmbedInsertCommand
EmbedController.php in src/Controller/EmbedController.php

File

src/Ajax/EmbedInsertCommand.php, line 14

Namespace

Drupal\embed\Ajax
View source
class EmbedInsertCommand implements CommandInterface, CommandWithAttachedAssetsInterface {
  use CommandWithAttachedAssetsTrait;

  /**
   * The content for the matched element(s).
   *
   * Either a render array or an HTML string.
   *
   * @var string|array
   */
  protected $content;

  /**
   * Constructs an EmbedInsertCommand object.
   *
   * @param string|array $content
   *   The content that will be inserted in the matched element(s), either a
   *   render array or an HTML string.
   */
  public function __construct($content) {
    $this->content = $content;
  }

  /**
   * {@inheritdoc}
   */
  public function render() {
    return [
      'command' => 'embed_insert',
      'data' => $this
        ->getRenderedContent(),
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommandWithAttachedAssetsTrait::$attachedAssets protected property The attached assets for this Ajax command.
CommandWithAttachedAssetsTrait::getAttachedAssets public function Gets the attached assets.
CommandWithAttachedAssetsTrait::getRenderedContent protected function Processes the content for output.
EmbedInsertCommand::$content protected property The content for the matched element(s).
EmbedInsertCommand::render public function Return an array to be run through json_encode and sent to the client. Overrides CommandInterface::render
EmbedInsertCommand::__construct public function Constructs an EmbedInsertCommand object.