EmbedInsertCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A render() 0 6 1
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