Skip to content
Snippets Groups Projects
Commit 1d1c63d2 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2204635 by Berdir: Convert ViewsHandlerManager to DefaultPluginManager.

parent 45e61d20
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
<?php
/**
* @file
* Contains \Drupal\views\Plugin\Discovery\ViewsHandlerDiscovery.
*/
namespace Drupal\views\Plugin\Discovery;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
/**
* Defines a discovery mechanism to find Views handlers in PSR-0 namespaces.
*/
class ViewsHandlerDiscovery extends AnnotatedClassDiscovery {
/**
* The type of handler being discovered.
*
* @var string
*/
protected $type;
/**
* Constructs a ViewsHandlerDiscovery object.
*
* @param string $type
* The plugin type, for example filter.
* @param \Traversable $root_namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations,
*/
function __construct($type, \Traversable $root_namespaces) {
$this->type = $type;
parent::__construct("Plugin/views/$type", $root_namespaces, 'Drupal\Component\Annotation\PluginID');
}
/**
* {@inheritdoc}
*/
public function getDefinitions() {
// Add the plugin_type to the definition.
$definitions = parent::getDefinitions();
foreach ($definitions as $key => $definition) {
$definitions[$key]['plugin_type'] = $this->type;
}
return $definitions;
}
}
...@@ -8,16 +8,16 @@ ...@@ -8,16 +8,16 @@
namespace Drupal\views\Plugin; namespace Drupal\views\Plugin;
use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Plugin\Factory\ContainerFactory; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\Discovery\CacheDecorator; use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\views\Plugin\Discovery\ViewsHandlerDiscovery; use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\views\ViewsData; use Drupal\views\ViewsData;
/** /**
* Plugin type manager for all views handlers. * Plugin type manager for all views handlers.
*/ */
class ViewsHandlerManager extends PluginManagerBase { class ViewsHandlerManager extends DefaultPluginManager {
/** /**
* The views data cache. * The views data cache.
...@@ -45,18 +45,25 @@ class ViewsHandlerManager extends PluginManagerBase { ...@@ -45,18 +45,25 @@ class ViewsHandlerManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations, * keyed by the corresponding namespace to look for plugin implementations,
* @param \Drupal\views\ViewsData $views_data * @param \Drupal\views\ViewsData $views_data
* The views data cache. * The views data cache.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
*/ */
public function __construct($handler_type, \Traversable $namespaces, ViewsData $views_data) { public function __construct($handler_type, \Traversable $namespaces, ViewsData $views_data, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) {
$this->discovery = new ViewsHandlerDiscovery($handler_type, $namespaces); parent::__construct("Plugin/views/$handler_type", $namespaces, $module_handler, 'Drupal\Component\Annotation\PluginID');
$this->discovery = new CacheDecorator($this->discovery, "views:$handler_type", 'views_info');
$this->factory = new ContainerFactory($this); $this->setCacheBackend($cache_backend, $language_manager, "views:$handler_type");
$this->viewsData = $views_data; $this->viewsData = $views_data;
$this->handlerType = $handler_type; $this->handlerType = $handler_type;
$this->defaults = array(
'plugin_type' => $handler_type,
);
} }
/** /**
* Fetches a handler from the data cache. * Fetches a handler from the data cache.
* *
......
...@@ -4,10 +4,10 @@ services: ...@@ -4,10 +4,10 @@ services:
arguments: [access, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] arguments: [access, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.area: plugin.manager.views.area:
class: Drupal\views\Plugin\ViewsHandlerManager class: Drupal\views\Plugin\ViewsHandlerManager
arguments: [area, '@container.namespaces', '@views.views_data'] arguments: [area, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.argument: plugin.manager.views.argument:
class: Drupal\views\Plugin\ViewsHandlerManager class: Drupal\views\Plugin\ViewsHandlerManager
arguments: [argument, '@container.namespaces', '@views.views_data'] arguments: [argument, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.argument_default: plugin.manager.views.argument_default:
class: Drupal\views\Plugin\ViewsPluginManager class: Drupal\views\Plugin\ViewsPluginManager
arguments: [argument_default, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] arguments: [argument_default, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
...@@ -28,13 +28,13 @@ services: ...@@ -28,13 +28,13 @@ services:
arguments: [exposed_form, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] arguments: [exposed_form, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.field: plugin.manager.views.field:
class: Drupal\views\Plugin\ViewsHandlerManager class: Drupal\views\Plugin\ViewsHandlerManager
arguments: [field, '@container.namespaces', '@views.views_data'] arguments: [field, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.filter: plugin.manager.views.filter:
class: Drupal\views\Plugin\ViewsHandlerManager class: Drupal\views\Plugin\ViewsHandlerManager
arguments: [filter, '@container.namespaces', '@views.views_data'] arguments: [filter, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.join: plugin.manager.views.join:
class: Drupal\views\Plugin\ViewsHandlerManager class: Drupal\views\Plugin\ViewsHandlerManager
arguments: [join, '@container.namespaces', '@views.views_data'] arguments: [join, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.pager: plugin.manager.views.pager:
class: Drupal\views\Plugin\ViewsPluginManager class: Drupal\views\Plugin\ViewsPluginManager
arguments: [pager, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] arguments: [pager, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
...@@ -43,13 +43,13 @@ services: ...@@ -43,13 +43,13 @@ services:
arguments: [query, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] arguments: [query, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.relationship: plugin.manager.views.relationship:
class: Drupal\views\Plugin\ViewsHandlerManager class: Drupal\views\Plugin\ViewsHandlerManager
arguments: [relationship, '@container.namespaces', '@views.views_data'] arguments: [relationship, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.row: plugin.manager.views.row:
class: Drupal\views\Plugin\ViewsPluginManager class: Drupal\views\Plugin\ViewsPluginManager
arguments: [row, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] arguments: [row, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.sort: plugin.manager.views.sort:
class: Drupal\views\Plugin\ViewsHandlerManager class: Drupal\views\Plugin\ViewsHandlerManager
arguments: [sort, '@container.namespaces', '@views.views_data'] arguments: [sort, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler']
plugin.manager.views.style: plugin.manager.views.style:
class: Drupal\views\Plugin\ViewsPluginManager class: Drupal\views\Plugin\ViewsPluginManager
arguments: [style, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] arguments: [style, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment