DrupalEntity::getConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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