Commit 8c19f192 authored by alexpott's avatar alexpott

Issue #2034563 by dawehner: Switch field plugin managers to DefaultPluginManager.

parent a4c65bec
services:
plugin.manager.field.widget:
class: Drupal\field\Plugin\Type\Widget\WidgetPluginManager
arguments: ['@container.namespaces']
arguments: ['@container.namespaces', '@cache.field', '@module_handler', '@language_manager']
plugin.manager.field.formatter:
class: Drupal\field\Plugin\Type\Formatter\FormatterPluginManager
arguments: ['@container.namespaces']
arguments: ['@container.namespaces', '@cache.field', '@module_handler', '@language_manager']
field.info:
class: Drupal\field\FieldInfo
arguments: ['@cache.field', '@config.factory', '@module_handler']
......
......@@ -9,6 +9,10 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManager;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
......@@ -17,7 +21,7 @@
/**
* Plugin type manager for field formatters.
*/
class FormatterPluginManager extends PluginManagerBase {
class FormatterPluginManager extends DefaultPluginManager {
/**
* An array of formatter options for each field type.
......@@ -31,13 +35,21 @@ class FormatterPluginManager extends PluginManagerBase {
*
* @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\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Language\LanguageManager $language_manager
* The language manager.
*/
public function __construct(\Traversable $namespaces) {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager) {
$annotation_namespaces = array('Drupal\field\Annotation' => $namespaces['Drupal\field']);
$this->discovery = new AnnotatedClassDiscovery('field/formatter', $namespaces, $annotation_namespaces, 'Drupal\field\Annotation\FieldFormatter');
$this->discovery = new AlterDecorator($this->discovery, 'field_formatter_info');
$this->discovery = new CacheDecorator($this->discovery, 'field_formatter_types', 'field');
parent::__construct('field/formatter', $namespaces, $annotation_namespaces, 'Drupal\field\Annotation\FieldFormatter');
$this->setCacheBackend($cache_backend, $language_manager, 'field_formatter_types');
$this->alterInfo($module_handler, 'field_formatter_info');
}
/**
......
......@@ -9,6 +9,10 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Discovery\ProcessDecorator;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManager;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
......@@ -16,7 +20,7 @@
/**
* Plugin type manager for field widgets.
*/
class WidgetPluginManager extends PluginManagerBase {
class WidgetPluginManager extends DefaultPluginManager {
/**
* An array of widget options for each field type.
......@@ -40,15 +44,21 @@ class WidgetPluginManager extends PluginManagerBase {
*
* @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\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Language\LanguageManager $language_manager
* The language manager.
*/
public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('field/widget', $namespaces);
$this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition'));
$this->discovery = new AlterDecorator($this->discovery, 'field_widget_info');
$this->discovery = new CacheDecorator($this->discovery, 'field_widget_types', 'field');
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager) {
parent::__construct('field/widget', $namespaces);
$this->factory = new WidgetFactory($this->discovery);
$this->setCacheBackend($cache_backend, $language_manager, 'field_widget_types');
$this->alterInfo($module_handler, 'field_widget_info');
$this->factory = new WidgetFactory($this);
}
/**
......
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