Version 1
[yaffs-website] / web / modules / contrib / embed / src / Ajax / EmbedInsertCommand.php
diff --git a/web/modules/contrib/embed/src/Ajax/EmbedInsertCommand.php b/web/modules/contrib/embed/src/Ajax/EmbedInsertCommand.php
new file mode 100644 (file)
index 0000000..afada20
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+namespace Drupal\embed\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 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(),
+    ];
+  }
+
+}