Commit fc29f3cc authored by aspilicious's avatar aspilicious Committed by tim.plunkett

Issue #1794844 by aspilicious: One manager for each use case.

parent 489a28a5
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\JoinManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
class JoinManager extends PluginManagerBase {
/**
* A list of Drupal core modules.
*
* @var array
*/
protected $coreModules = array();
/**
* Constructs a JoinManager object.
*/
public function __construct() {
// @todo Remove this hack in http://drupal.org/node/1708404.
views_init();
$this->discovery = new CacheDecorator(new AnnotatedClassDiscovery('views', 'join'), 'views:join', 'views_info');
$this->factory = new DefaultFactory($this);
$this->coreModules = views_core_modules();
}
/**
* Overrides Drupal\Component\Plugin\PluginManagerBase::processDefinition().
*/
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
$module = isset($definition['module']) ? $definition['module'] : 'views';
$module_dir = in_array($module, $this->coreModules) ? 'views' : $module;
$definition += array(
'module' => $module_dir,
);
}
}
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\views\Plugin\Type\ViewsPluginManager.
* Definition of Drupal\views\Plugin\Type\PluginManager.
*/
namespace Drupal\views\Plugin\Type;
......@@ -12,7 +12,7 @@
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
class ViewsPluginManager extends PluginManagerBase {
class PluginManager extends PluginManagerBase {
/**
* A list of Drupal core modules.
......@@ -21,11 +21,14 @@ class ViewsPluginManager extends PluginManagerBase {
*/
protected $coreModules = array();
/**
* Constructs a PluginManager object.
*/
public function __construct($type) {
// @todo Remove this hack in http://drupal.org/node/1708404.
views_init();
$this->discovery = new CacheDecorator(new AnnotatedClassDiscovery('views', $type), 'views:' . $type, 'views');
$this->discovery = new CacheDecorator(new AnnotatedClassDiscovery('views', $type), 'views:' . $type, 'views_info');
$this->factory = new DefaultFactory($this);
$this->coreModules = views_core_modules();
$this->defaults += array(
......
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\WizardManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
class WizardManager extends PluginManagerBase {
/**
* A list of Drupal core modules.
*
* @var array
*/
protected $coreModules = array();
/**
* Constructs a WizardManager object.
*/
public function __construct() {
// @todo Remove this hack in http://drupal.org/node/1708404.
views_init();
$this->discovery = new CacheDecorator(new AnnotatedClassDiscovery('views', 'wizard'), 'views:wizard', 'views_info');
$this->factory = new DefaultFactory($this);
$this->coreModules = views_core_modules();
}
/**
* Overrides Drupal\Component\Plugin\PluginManagerBase::processDefinition().
*/
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
$module = isset($definition['module']) ? $definition['module'] : 'views';
$module_dir = in_array($module, $this->coreModules) ? 'views' : $module;
$definition += array(
'module' => $module_dir,
);
}
}
......@@ -21,8 +21,16 @@ class ViewsBundle extends Bundle {
*/
public function build(ContainerBuilder $container) {
foreach (ViewExecutable::getPluginTypes() as $type) {
$container->register("plugin.manager.views.$type", 'Drupal\views\Plugin\Type\ViewsPluginManager')
->addArgument($type);
if ($type == 'join') {
$container->register('plugin.manager.views.join', 'Drupal\views\Plugin\Type\JoinManager');
}
elseif ($type == 'wizard') {
$container->register('plugin.manager.views.wizard', 'Drupal\views\Plugin\Type\WizardManager');
}
else {
$container->register("plugin.manager.views.$type", 'Drupal\views\Plugin\Type\PluginManager')
->addArgument($type);
}
}
}
......
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