Commit 96b23549 authored by alexpott's avatar alexpott

Issue #1992744 by quicksketch: Add a dedicated @Editor plugin annotation.

parent 1b963bba
......@@ -2,20 +2,20 @@
/**
* @file
* Contains \Drupal\ckeditor\Plugin\editor\editor\CKEditor.
* Contains \Drupal\ckeditor\Plugin\Editor\CKEditor.
*/
namespace Drupal\ckeditor\Plugin\editor\editor;
namespace Drupal\ckeditor\Plugin\Editor;
use Drupal\editor\Plugin\EditorBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\editor\Annotation\Editor;
use Drupal\Core\Annotation\Translation;
use Drupal\editor\Plugin\Core\Entity\Editor;
use Drupal\editor\Plugin\Core\Entity\Editor as EditorEntity;
/**
* Defines a CKEditor-based text editor for Drupal.
*
* @Plugin(
* @Editor(
* id = "ckeditor",
* label = @Translation("CKEditor"),
* module = "ckeditor",
......@@ -47,7 +47,7 @@ public function getDefaultSettings() {
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::settingsForm().
*/
public function settingsForm(array $form, array &$form_state, Editor $editor) {
public function settingsForm(array $form, array &$form_state, EditorEntity $editor) {
$module_path = drupal_get_path('module', 'ckeditor');
$manager = drupal_container()->get('plugin.manager.ckeditor.plugin');
......@@ -106,7 +106,7 @@ public function settingsFormSubmit(array $form, array &$form_state) {
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::getJSSettings().
*/
public function getJSSettings(Editor $editor) {
public function getJSSettings(EditorEntity $editor) {
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
$settings = array();
......@@ -145,7 +145,7 @@ public function getJSSettings(Editor $editor) {
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::getLibraries().
*/
public function getLibraries(Editor $editor) {
public function getLibraries(EditorEntity $editor) {
return array(
array('ckeditor', 'drupal.ckeditor'),
);
......@@ -161,7 +161,7 @@ public function getLibraries(Editor $editor) {
* @return array
* An array containing the "toolbar" configuration.
*/
public function buildToolbarJSSetting(Editor $editor) {
public function buildToolbarJSSetting(EditorEntity $editor) {
$toolbar = array();
foreach ($editor->settings['toolbar']['buttons'] as $row_number => $row) {
$button_group = array();
......@@ -192,7 +192,7 @@ public function buildToolbarJSSetting(Editor $editor) {
* @return array
* An array containing the "contentsCss" configuration.
*/
public function buildContentsCssJSSetting(Editor $editor) {
public function buildContentsCssJSSetting(EditorEntity $editor) {
$css = array(
drupal_get_path('module', 'ckeditor') . '/css/ckeditor-iframe.css',
);
......
......@@ -9,7 +9,7 @@
use Drupal\simpletest\DrupalUnitTestBase;
use Drupal\editor\Plugin\EditorManager;
use Drupal\ckeditor\Plugin\editor\editor\CKEditor;
use Drupal\ckeditor\Plugin\Editor\CKEditor;
/**
* Tests for the 'CKEditor' text editor plugin.
......@@ -26,7 +26,7 @@ class CKEditorTest extends DrupalUnitTestBase {
/**
* An instance of the "CKEditor" text editor plugin.
*
* @var \Drupal\ckeditor\Plugin\editor\editor\CKEditor;
* @var \Drupal\ckeditor\Plugin\Editor\CKEditor;
*/
protected $ckeditor;
......
<?php
/**
* @file
* Contains \Drupal\editor\Annotation\Editor.
*/
namespace Drupal\editor\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines an Editor annotation object.
*
* @Annotation
*/
class Editor extends Plugin {
/**
* The plugin ID.
*
* @var string
*/
public $id;
/**
* The human-readable name of the editor plugin.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $label;
/**
* The name of the module providing the editor plugin.
*
* @var string
*/
public $module;
/**
* Whether the editor supports the inline editing provided by the Edit module.
*
* @var boolean
*/
public $supports_inline_editing;
}
......@@ -29,7 +29,7 @@
* A complete sample plugin definition should be defined as in this example:
*
* @code
* @Plugin(
* @Editor(
* id = "myeditor",
* label = @Translation("My Editor"),
* module = "mymodule"
......
......@@ -27,7 +27,8 @@ class EditorManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations,
*/
public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('editor/editor', $namespaces);
$annotation_namespaces = array('Drupal\editor\Annotation' => $namespaces['Drupal\editor']);
$this->discovery = new AnnotatedClassDiscovery('Editor', $namespaces, $annotation_namespaces, 'Drupal\editor\Annotation\Editor');
$this->discovery = new AlterDecorator($this->discovery, 'editor_info');
$this->discovery = new CacheDecorator($this->discovery, 'editor');
$this->factory = new DefaultFactory($this->discovery);
......
......@@ -2,20 +2,20 @@
/**
* @file
* Contains \Drupal\editor_test\Plugin\editor\editor\UnicornEditor.
* Contains \Drupal\editor_test\Plugin\Editor\UnicornEditor.
*/
namespace Drupal\editor_test\Plugin\editor\editor;
namespace Drupal\editor_test\Plugin\Editor;
use Drupal\editor\Plugin\EditorBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\editor\Annotation\Editor;
use Drupal\Core\Annotation\Translation;
use Drupal\editor\Plugin\Core\Entity\Editor;
use Drupal\editor\Plugin\Core\Entity\Editor as EditorEntity;
/**
* Defines a Unicorn-powered text editor for Drupal.
*
* @Plugin(
* @Editor(
* id = "unicorn",
* label = @Translation("Unicorn Editor"),
* module = "editor_test",
......@@ -34,7 +34,7 @@ function getDefaultSettings() {
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::settingsForm().
*/
function settingsForm(array $form, array &$form_state, Editor $editor) {
function settingsForm(array $form, array &$form_state, EditorEntity $editor) {
$form['foo'] = array('#type' => 'textfield', '#default_value' => 'bar');
return $form;
}
......@@ -42,7 +42,7 @@ function settingsForm(array $form, array &$form_state, Editor $editor) {
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::getJSSettings().
*/
function getJSSettings(Editor $editor) {
function getJSSettings(EditorEntity $editor) {
$settings = array();
if ($editor->settings['ponies too']) {
$settings['ponyModeEnabled'] = TRUE;
......@@ -53,7 +53,7 @@ function getJSSettings(Editor $editor) {
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::getLibraries().
*/
public function getLibraries(Editor $editor) {
public function getLibraries(EditorEntity $editor) {
return array(
array('edit_test', 'unicorn'),
);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment