Commit aaa2408c authored by alexpott's avatar alexpott
Browse files

Issue #2039433 by Wim Leers: Convert EditorManager to extend DefaultPluginManager.

parent 566ebfd9
services:
plugin.manager.editor:
class: Drupal\editor\Plugin\EditorManager
arguments: ['@container.namespaces']
arguments: ['@container.namespaces', '@cache.cache', '@language_manager', '@module_handler']
......@@ -7,31 +7,34 @@
namespace Drupal\editor\Plugin;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Discovery\ProcessDecorator;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Core\Plugin\Factory\ContainerFactory;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManager;
/**
* Configurable text editor manager.
*/
class EditorManager extends PluginManagerBase {
class EditorManager extends DefaultPluginManager {
/**
* Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct().
* Constructs an EditorManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations,
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Language\LanguageManager $language_manager
* The language manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
*/
public function __construct(\Traversable $namespaces) {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) {
$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 ContainerFactory($this->discovery);
parent::__construct('Editor', $namespaces, $annotation_namespaces, 'Drupal\editor\Annotation\Editor');
$this->alterInfo($module_handler, 'editor_info');
$this->setCacheBackend($cache_backend, $language_manager, 'editor');
}
/**
......
......@@ -66,7 +66,7 @@ function setUp() {
* Tests the configurable text editor manager.
*/
function testManager() {
$this->editorManager = new EditorManager($this->container->get('container.namespaces'));
$this->editorManager = $this->container->get('plugin.manager.editor');
// Case 1: no text editor available:
// - listOptions() should return an empty list of options
......
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