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

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

parent d4a11ad3
services:
plugin.manager.edit.editor:
class: Drupal\edit\Plugin\EditorManager
class: Drupal\edit\Plugin\InPlaceEditorManager
arguments: ['@container.namespaces']
access_check.edit.entity_field:
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 @@
/**
* @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\Component\Annotation\Plugin;
use Drupal\edit\Annotation\InPlaceEditor;
use Drupal\field\Plugin\Core\Entity\FieldInstance;
/**
* Defines the direct editor.
*
* @Plugin(
* @InPlaceEditor(
* id = "direct",
* module = "edit"
* )
......
......@@ -2,19 +2,19 @@
/**
* @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\Component\Annotation\Plugin;
use Drupal\edit\Annotation\InPlaceEditor;
use Drupal\field\Plugin\Core\Entity\FieldInstance;
/**
* Defines the form editor.
*
* @Plugin(
* @InPlaceEditor(
* id = "form",
* module = "edit"
* )
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\edit\Plugin\EditorManager.
* Contains \Drupal\edit\Plugin\InPlaceEditorManager.
*/
namespace Drupal\edit\Plugin;
......@@ -19,7 +19,7 @@
*
* The form editor must always be available.
*/
class EditorManager extends PluginManagerBase {
class InPlaceEditorManager extends PluginManagerBase {
/**
* Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct().
......@@ -29,7 +29,8 @@ class EditorManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations,
*/
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 AlterDecorator($this->discovery, 'edit_editor');
$this->discovery = new CacheDecorator($this->discovery, 'edit:editor');
......
......@@ -7,7 +7,7 @@
namespace Drupal\edit\Tests;
use Drupal\edit\Plugin\EditorManager;
use Drupal\edit\Plugin\InPlaceEditorManager;
use Drupal\edit\EditorSelector;
/**
......
......@@ -10,7 +10,7 @@
use Drupal\Core\Language\Language;
use Drupal\edit\EditorSelector;
use Drupal\edit\MetadataGenerator;
use Drupal\edit\Plugin\EditorManager;
use Drupal\edit\Plugin\InPlaceEditorManager;
use Drupal\edit_test\MockEditEntityFieldAccessCheck;
/**
......
......@@ -2,19 +2,19 @@
/**
* @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\Component\Annotation\Plugin;
use Drupal\edit\Annotation\InPlaceEditor;
use Drupal\field\Plugin\Core\Entity\FieldInstance;
/**
* Defines the wysiwyg editor.
*
* @Plugin(
* @InPlaceEditor(
* id = "wysiwyg",
* alternativeTo = {"direct"},
* module = "edit_test"
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\editor\Plugin\EditorManager.
* Contains \Drupal\editor\Plugin\InPlaceEditorManager.
*/
namespace Drupal\editor\Plugin;
......
......@@ -2,13 +2,13 @@
/**
* @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\Annotation\Plugin;
use Drupal\edit\Annotation\InPlaceEditor;
use Drupal\Core\Annotation\Translation;
use Drupal\edit\EditPluginInterface;
use Drupal\field\Plugin\Core\Entity\FieldInstance;
......@@ -16,7 +16,7 @@
/**
* Defines the formatted text editor.
*
* @Plugin(
* @InPlaceEditor(
* id = "editor",
* alternativeTo = {"direct"},
* module = "editor"
......
......@@ -10,7 +10,7 @@
use Drupal\Core\Language\Language;
use Drupal\edit\EditorSelector;
use Drupal\edit\MetadataGenerator;
use Drupal\edit\Plugin\EditorManager;
use Drupal\edit\Plugin\InPlaceEditorManager;
use Drupal\edit\Tests\EditTestBase;
use Drupal\edit_test\MockEditEntityFieldAccessCheck;
use Drupal\editor\EditorController;
......@@ -123,7 +123,7 @@ protected function getSelectedEditor($items, $field_name, $view_mode = 'default'
* format compatibility.
*/
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);
// Pretend there is an entity with these items for the field.
......@@ -147,7 +147,7 @@ function testEditorSelection() {
* Tests (custom) metadata when the formatted text editor is used.
*/
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->editorSelector = new 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