Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / embed / src / Ajax / EmbedInsertCommand.php
1 <?php
2
3 namespace Drupal\embed\Ajax;
4
5 use Drupal\Core\Ajax\CommandInterface;
6 use Drupal\Core\Ajax\CommandWithAttachedAssetsTrait;
7 use Drupal\Core\Ajax\CommandWithAttachedAssetsInterface;
8
9 /**
10  * AJAX command for inserting an embedded item in an editor.
11  *
12  * @ingroup ajax
13  */
14 class EmbedInsertCommand implements CommandInterface, CommandWithAttachedAssetsInterface {
15
16   use CommandWithAttachedAssetsTrait;
17
18   /**
19    * The content for the matched element(s).
20    *
21    * Either a render array or an HTML string.
22    *
23    * @var string|array
24    */
25   protected $content;
26
27   /**
28    * Constructs an EmbedInsertCommand object.
29    *
30    * @param string|array $content
31    *   The content that will be inserted in the matched element(s), either a
32    *   render array or an HTML string.
33    */
34   public function __construct($content) {
35     $this->content = $content;
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function render() {
42     return [
43       'command' => 'embed_insert',
44       'data' => $this->getRenderedContent(),
45     ];
46   }
47
48 }