Completed
Pull Request — 8.x-1.x (#200)
by
unknown
03:44
created

DrupalEntity::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
c 2
b 0
f 1
nc 1
nop 4
dl 0
loc 7
rs 9.4285
1
<?php
2
3
/**
4
 * @file
5
 * Contains \Drupal\entity_embed\Plugin\CKEditorPlugin\DrupalEntity.
6
 */
7
8
namespace Drupal\entity_embed\Plugin\CKEditorPlugin;
9
10
use Drupal\editor\Entity\Editor;
11
use Drupal\embed\EmbedButtonInterface;
12
use Drupal\embed\EmbedCKEditorPluginBase;
13
use Symfony\Component\DependencyInjection\ContainerInterface;
14
15
/**
16
 * Defines the "drupalentity" plugin.
17
 *
18
 * @CKEditorPlugin(
19
 *   id = "drupalentity",
20
 *   label = @Translation("Entity"),
21
 *   embed_type_id = "entity"
22
 * )
23
 */
24
class DrupalEntity extends EmbedCKEditorPluginBase {
25
26
  /**
27
   * {@inheritdoc}
28
   */
29
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
30
    $configuration['inline'] = $container->get('config.factory')
31
      ->get('entity_embed.settings')
32
      ->get('inline');
33
34
    return parent::create($container, $configuration, $plugin_id, $plugin_definition);
35
  }
36
37
  /**
38
   * {@inheritdoc}
39
   */
40
  protected function getButton(EmbedButtonInterface $embed_button) {
41
    $button = parent::getButton($embed_button);
42
    $button['entity_type'] = $embed_button->getTypeSetting('entity_type');
43
    return $button;
44
  }
45
46
  /**
47
   * {@inheritdoc}
48
   */
49
  public function getFile() {
50
    return drupal_get_path('module', 'entity_embed') . '/js/plugins/drupalentity/plugin.js';
51
  }
52
53
  /**
54
   * {@inheritdoc}
55
   */
56
  public function getConfig(Editor $editor) {
57
    return array(
58
      'DrupalEntity_dialogTitleAdd' => t('Insert entity'),
59
      'DrupalEntity_dialogTitleEdit' => t('Edit entity'),
60
      'DrupalEntity_buttons' => $this->getButtons(),
61
      'DrupalEntity_inline' => $this->configuration['inline'],
62
    );
63
  }
64
65
}
66