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
|
|
|
|