DrupalEntity   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getButton() 0 5 1
A getFile() 0 3 1
A getConfig() 0 7 1
1
<?php
2
3
namespace Drupal\entity_embed\Plugin\CKEditorPlugin;
4
5
use Drupal\editor\Entity\Editor;
6
use Drupal\embed\EmbedButtonInterface;
7
use Drupal\embed\EmbedCKEditorPluginBase;
8
9
/**
10
 * Defines the "drupalentity" plugin.
11
 *
12
 * @CKEditorPlugin(
13
 *   id = "drupalentity",
14
 *   label = @Translation("Entity"),
15
 *   embed_type_id = "entity"
16
 * )
17
 */
18
class DrupalEntity extends EmbedCKEditorPluginBase {
19
20
  /**
21
   * {@inheritdoc}
22
   */
23
  protected function getButton(EmbedButtonInterface $embed_button) {
24
    $button = parent::getButton($embed_button);
25
    $button['entity_type'] = $embed_button->getTypeSetting('entity_type');
26
    return $button;
27
  }
28
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function getFile() {
33
    return drupal_get_path('module', 'entity_embed') . '/js/plugins/drupalentity/plugin.js';
34
  }
35
36
  /**
37
   * {@inheritdoc}
38
   */
39
  public function getConfig(Editor $editor) {
40
    return array(
41
      'DrupalEntity_dialogTitleAdd' => t('Insert entity'),
42
      'DrupalEntity_dialogTitleEdit' => t('Edit entity'),
43
      'DrupalEntity_buttons' => $this->getButtons(),
44
    );
45
  }
46
47
}
48