EmbedInsertCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
}
49