Version 1
[yaffs-website] / web / modules / contrib / entity_embed / src / Plugin / CKEditorPlugin / DrupalEntity.php
diff --git a/web/modules/contrib/entity_embed/src/Plugin/CKEditorPlugin/DrupalEntity.php b/web/modules/contrib/entity_embed/src/Plugin/CKEditorPlugin/DrupalEntity.php
new file mode 100644 (file)
index 0000000..2a6fa14
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+namespace Drupal\entity_embed\Plugin\CKEditorPlugin;
+
+use Drupal\editor\Entity\Editor;
+use Drupal\embed\EmbedButtonInterface;
+use Drupal\embed\EmbedCKEditorPluginBase;
+
+/**
+ * Defines the "drupalentity" plugin.
+ *
+ * @CKEditorPlugin(
+ *   id = "drupalentity",
+ *   label = @Translation("Entity"),
+ *   embed_type_id = "entity"
+ * )
+ */
+class DrupalEntity extends EmbedCKEditorPluginBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getButton(EmbedButtonInterface $embed_button) {
+    $button = parent::getButton($embed_button);
+    $button['entity_type'] = $embed_button->getTypeSetting('entity_type');
+    return $button;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFile() {
+    return drupal_get_path('module', 'entity_embed') . '/js/plugins/drupalentity/plugin.js';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getConfig(Editor $editor) {
+    return array(
+      'DrupalEntity_dialogTitleAdd' => t('Insert entity'),
+      'DrupalEntity_dialogTitleEdit' => t('Edit entity'),
+      'DrupalEntity_buttons' => $this->getButtons(),
+    );
+  }
+
+}