Issue #2204635 by Berdir: Convert ViewsHandlerManager to DefaultPluginManager.
parent
45e61d20d1
commit
1d1c63d2a7
|
@ -1,50 +0,0 @@
|
|||
<?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 @@
|
|||
namespace Drupal\views\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginException;
|
||||
use Drupal\Component\Plugin\PluginManagerBase;
|
||||
use Drupal\Core\Plugin\Factory\ContainerFactory;
|
||||
use Drupal\Core\Plugin\Discovery\CacheDecorator;
|
||||
use Drupal\views\Plugin\Discovery\ViewsHandlerDiscovery;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Plugin\DefaultPluginManager;
|
||||
use Drupal\views\ViewsData;
|
||||
|
||||
/**
|
||||
* Plugin type manager for all views handlers.
|
||||
*/
|
||||
class ViewsHandlerManager extends PluginManagerBase {
|
||||
class ViewsHandlerManager extends DefaultPluginManager {
|
||||
|
||||
/**
|
||||
* The views data cache.
|
||||
|
@ -45,18 +45,25 @@ class ViewsHandlerManager extends PluginManagerBase {
|
|||
* keyed by the corresponding namespace to look for plugin implementations,
|
||||
* @param \Drupal\views\ViewsData $views_data
|
||||
* 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) {
|
||||
$this->discovery = new ViewsHandlerDiscovery($handler_type, $namespaces);
|
||||
$this->discovery = new CacheDecorator($this->discovery, "views:$handler_type", 'views_info');
|
||||
public function __construct($handler_type, \Traversable $namespaces, ViewsData $views_data, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) {
|
||||
parent::__construct("Plugin/views/$handler_type", $namespaces, $module_handler, 'Drupal\Component\Annotation\PluginID');
|
||||
|
||||
$this->factory = new ContainerFactory($this);
|
||||
$this->setCacheBackend($cache_backend, $language_manager, "views:$handler_type");
|
||||
|
||||
$this->viewsData = $views_data;
|
||||
$this->handlerType = $handler_type;
|
||||
$this->defaults = array(
|
||||
'plugin_type' => $handler_type,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetches a handler from the data cache.
|
||||
*
|
||||
|
|
|
@ -4,10 +4,10 @@ services:
|
|||
arguments: [access, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
|
||||
plugin.manager.views.area:
|
||||
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:
|
||||
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:
|
||||
class: Drupal\views\Plugin\ViewsPluginManager
|
||||
arguments: [argument_default, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
|
||||
|
@ -28,13 +28,13 @@ services:
|
|||
arguments: [exposed_form, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
|
||||
plugin.manager.views.field:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
class: Drupal\views\Plugin\ViewsPluginManager
|
||||
arguments: [pager, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
|
||||
|
@ -43,13 +43,13 @@ services:
|
|||
arguments: [query, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
|
||||
plugin.manager.views.relationship:
|
||||
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:
|
||||
class: Drupal\views\Plugin\ViewsPluginManager
|
||||
arguments: [row, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
|
||||
plugin.manager.views.sort:
|
||||
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:
|
||||
class: Drupal\views\Plugin\ViewsPluginManager
|
||||
arguments: [style, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler']
|
||||
|
|
Loading…
Reference in New Issue