diff --git a/lib/Drupal/views/Plugin/Type/JoinManager.php b/lib/Drupal/views/Plugin/Type/JoinManager.php new file mode 100644 index 0000000000000000000000000000000000000000..0e4801fdbebbc083b488bf553310896720add365 --- /dev/null +++ b/lib/Drupal/views/Plugin/Type/JoinManager.php @@ -0,0 +1,51 @@ +<?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, + ); + } + +} diff --git a/lib/Drupal/views/Plugin/Type/ViewsPluginManager.php b/lib/Drupal/views/Plugin/Type/PluginManager.php similarity index 88% rename from lib/Drupal/views/Plugin/Type/ViewsPluginManager.php rename to lib/Drupal/views/Plugin/Type/PluginManager.php index 535ac61826f887f99dd5085c98d7eb9ff2cf5f77..4c7ffd9e23796845887c3491e70c9bcd4a0caa1c 100644 --- a/lib/Drupal/views/Plugin/Type/ViewsPluginManager.php +++ b/lib/Drupal/views/Plugin/Type/PluginManager.php @@ -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( diff --git a/lib/Drupal/views/Plugin/Type/WizardManager.php b/lib/Drupal/views/Plugin/Type/WizardManager.php new file mode 100644 index 0000000000000000000000000000000000000000..336c171c59e33785423c768c291870609ab8b9e0 --- /dev/null +++ b/lib/Drupal/views/Plugin/Type/WizardManager.php @@ -0,0 +1,51 @@ +<?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, + ); + } + +} diff --git a/lib/Drupal/views/ViewsBundle.php b/lib/Drupal/views/ViewsBundle.php index a432e3563a34f03038bba9e9ba79dfc1f3f56255..7a85ff059640eea713c5262bc5dd9a87c4a2768a 100644 --- a/lib/Drupal/views/ViewsBundle.php +++ b/lib/Drupal/views/ViewsBundle.php @@ -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); + } } }