You are here

InsertViewCommand.php in Advanced Insert View 8

Same filename and directory in other branches
  1. 2.0.x src/Ajax/InsertViewCommand.php

File

src/Ajax/InsertViewCommand.php
View source
<?php

namespace Drupal\insert_view_adv\Ajax;

use Drupal\Core\Ajax\CommandInterface;
use Drupal\Core\Ajax\CommandWithAttachedAssetsTrait;
use Drupal\Core\Ajax\CommandWithAttachedAssetsInterface;

/**
 * AJAX command for inserting an embedded item in an editor.
 *
 * @ingroup ajax
 */
class InsertViewCommand 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' => 'insert_view_adv_insert',
      'data' => $this
        ->getRenderedContent(),
    ];
  }

}

Classes

Namesort descending Description
InsertViewCommand AJAX command for inserting an embedded item in an editor.