Commit 93e80155 authored by alexpott's avatar alexpott
Browse files

Issue #1987140 by damiankloip: Add a dedicated @InPlaceEditor plugin annotation.

parent d4a11ad3
services: services:
plugin.manager.edit.editor: plugin.manager.edit.editor:
class: Drupal\edit\Plugin\EditorManager class: Drupal\edit\Plugin\InPlaceEditorManager
arguments: ['@container.namespaces'] arguments: ['@container.namespaces']
access_check.edit.entity_field: access_check.edit.entity_field:
class: Drupal\edit\Access\EditEntityFieldAccessCheck class: Drupal\edit\Access\EditEntityFieldAccessCheck
......
<?php
/**
* @file
* Contains \Drupal\edit\Annotation\InPlaceEditor.
*/
namespace Drupal\edit\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Defines an InPlaceEditor annotation object.
*
* @Annotation
*/
class InPlaceEditor extends Plugin {
/**
* The plugin ID.
*
* @var string
*/
public $id;
/**
* An array of in-place editors that have registered themselves as
* alternatives to this in-place editor.
*
* @var array
*/
public $alternativeTo;
/**
* The name of the module providing the in-place editor plugin.
*
* @var string
*/
public $module;
}
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
/** /**
* @file * @file
* Contains \Drupal\edit\Plugin\edit\editor\DirectEditor. * Contains \Drupal\edit\Plugin\InPlaceEditor\DirectEditor.
*/ */
namespace Drupal\edit\Plugin\edit\editor; namespace Drupal\edit\Plugin\InPlaceEditor;
use Drupal\edit\EditorBase; use Drupal\edit\EditorBase;
use Drupal\Component\Annotation\Plugin; use Drupal\edit\Annotation\InPlaceEditor;
use Drupal\field\Plugin\Core\Entity\FieldInstance; use Drupal\field\Plugin\Core\Entity\FieldInstance;
/** /**
* Defines the direct editor. * Defines the direct editor.
* *
* @Plugin( * @InPlaceEditor(
* id = "direct", * id = "direct",
* module = "edit" * module = "edit"
* ) * )
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
/** /**
* @file * @file
* Contains \Drupal\edit\Plugin\edit\editor\FormEditor. * Contains \Drupal\edit\Plugin\InPlaceEditor\FormEditor.
*/ */
namespace Drupal\edit\Plugin\edit\editor; namespace Drupal\edit\Plugin\InPlaceEditor;
use Drupal\edit\EditorBase; use Drupal\edit\EditorBase;
use Drupal\Component\Annotation\Plugin; use Drupal\edit\Annotation\InPlaceEditor;
use Drupal\field\Plugin\Core\Entity\FieldInstance; use Drupal\field\Plugin\Core\Entity\FieldInstance;
/** /**
* Defines the form editor. * Defines the form editor.
* *
* @Plugin( * @InPlaceEditor(
* id = "form", * id = "form",
* module = "edit" * module = "edit"
* ) * )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Contains \Drupal\edit\Plugin\EditorManager. * Contains \Drupal\edit\Plugin\InPlaceEditorManager.
*/ */
namespace Drupal\edit\Plugin; namespace Drupal\edit\Plugin;
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* *
* The form editor must always be available. * The form editor must always be available.
*/ */
class EditorManager extends PluginManagerBase { class InPlaceEditorManager extends PluginManagerBase {
/** /**
* Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct(). * Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct().
...@@ -29,7 +29,8 @@ class EditorManager extends PluginManagerBase { ...@@ -29,7 +29,8 @@ class EditorManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations, * keyed by the corresponding namespace to look for plugin implementations,
*/ */
public function __construct(\Traversable $namespaces) { public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('edit/editor', $namespaces); $annotation_namespaces = array('Drupal\edit\Annotation' => $namespaces['Drupal\edit']);
$this->discovery = new AnnotatedClassDiscovery('InPlaceEditor', $namespaces, $annotation_namespaces, 'Drupal\edit\Annotation\InPlaceEditor');
$this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition'));
$this->discovery = new AlterDecorator($this->discovery, 'edit_editor'); $this->discovery = new AlterDecorator($this->discovery, 'edit_editor');
$this->discovery = new CacheDecorator($this->discovery, 'edit:editor'); $this->discovery = new CacheDecorator($this->discovery, 'edit:editor');
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace Drupal\edit\Tests; namespace Drupal\edit\Tests;
use Drupal\edit\Plugin\EditorManager; use Drupal\edit\Plugin\InPlaceEditorManager;
use Drupal\edit\EditorSelector; use Drupal\edit\EditorSelector;
/** /**
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\edit\EditorSelector; use Drupal\edit\EditorSelector;
use Drupal\edit\MetadataGenerator; use Drupal\edit\MetadataGenerator;
use Drupal\edit\Plugin\EditorManager; use Drupal\edit\Plugin\InPlaceEditorManager;
use Drupal\edit_test\MockEditEntityFieldAccessCheck; use Drupal\edit_test\MockEditEntityFieldAccessCheck;
/** /**
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
/** /**
* @file * @file
* Contains \Drupal\edit_test\Plugin\edit\editor\WysiwygEditor. * Contains \Drupal\edit_test\Plugin\InPlaceEditor\WysiwygEditor.
*/ */
namespace Drupal\edit_test\Plugin\edit\editor; namespace Drupal\edit_test\Plugin\InPlaceEditor;
use Drupal\edit\EditorBase; use Drupal\edit\EditorBase;
use Drupal\Component\Annotation\Plugin; use Drupal\edit\Annotation\InPlaceEditor;
use Drupal\field\Plugin\Core\Entity\FieldInstance; use Drupal\field\Plugin\Core\Entity\FieldInstance;
/** /**
* Defines the wysiwyg editor. * Defines the wysiwyg editor.
* *
* @Plugin( * @InPlaceEditor(
* id = "wysiwyg", * id = "wysiwyg",
* alternativeTo = {"direct"}, * alternativeTo = {"direct"},
* module = "edit_test" * module = "edit_test"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Contains \Drupal\editor\Plugin\EditorManager. * Contains \Drupal\editor\Plugin\InPlaceEditorManager.
*/ */
namespace Drupal\editor\Plugin; namespace Drupal\editor\Plugin;
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
/** /**
* @file * @file
* Contains \Drupal\editor\Plugin\edit\editor\Editor. * Contains \Drupal\editor\Plugin\InPlaceEditor\Editor.
*/ */
namespace Drupal\editor\Plugin\edit\editor; namespace Drupal\editor\Plugin\InPlaceEditor;
use Drupal\Component\Plugin\PluginBase; use Drupal\Component\Plugin\PluginBase;
use Drupal\Component\Annotation\Plugin; use Drupal\edit\Annotation\InPlaceEditor;
use Drupal\Core\Annotation\Translation; use Drupal\Core\Annotation\Translation;
use Drupal\edit\EditPluginInterface; use Drupal\edit\EditPluginInterface;
use Drupal\field\Plugin\Core\Entity\FieldInstance; use Drupal\field\Plugin\Core\Entity\FieldInstance;
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
/** /**
* Defines the formatted text editor. * Defines the formatted text editor.
* *
* @Plugin( * @InPlaceEditor(
* id = "editor", * id = "editor",
* alternativeTo = {"direct"}, * alternativeTo = {"direct"},
* module = "editor" * module = "editor"
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\edit\EditorSelector; use Drupal\edit\EditorSelector;
use Drupal\edit\MetadataGenerator; use Drupal\edit\MetadataGenerator;
use Drupal\edit\Plugin\EditorManager; use Drupal\edit\Plugin\InPlaceEditorManager;
use Drupal\edit\Tests\EditTestBase; use Drupal\edit\Tests\EditTestBase;
use Drupal\edit_test\MockEditEntityFieldAccessCheck; use Drupal\edit_test\MockEditEntityFieldAccessCheck;
use Drupal\editor\EditorController; use Drupal\editor\EditorController;
...@@ -123,7 +123,7 @@ protected function getSelectedEditor($items, $field_name, $view_mode = 'default' ...@@ -123,7 +123,7 @@ protected function getSelectedEditor($items, $field_name, $view_mode = 'default'
* format compatibility. * format compatibility.
*/ */
function testEditorSelection() { function testEditorSelection() {
$this->editorManager = new EditorManager($this->container->get('container.namespaces')); $this->editorManager = new InPlaceEditorManager($this->container->get('container.namespaces'));
$this->editorSelector = new EditorSelector($this->editorManager); $this->editorSelector = new EditorSelector($this->editorManager);
// Pretend there is an entity with these items for the field. // Pretend there is an entity with these items for the field.
...@@ -147,7 +147,7 @@ function testEditorSelection() { ...@@ -147,7 +147,7 @@ function testEditorSelection() {
* Tests (custom) metadata when the formatted text editor is used. * Tests (custom) metadata when the formatted text editor is used.
*/ */
function testMetadata() { function testMetadata() {
$this->editorManager = new EditorManager($this->container->get('container.namespaces')); $this->editorManager = new InPlaceEditorManager($this->container->get('container.namespaces'));
$this->accessChecker = new MockEditEntityFieldAccessCheck(); $this->accessChecker = new MockEditEntityFieldAccessCheck();
$this->editorSelector = new EditorSelector($this->editorManager); $this->editorSelector = new EditorSelector($this->editorManager);
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
......
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