Issue #1862344 by damiankloip, tim.plunkett: Combine the Views plugin managers.

8.0.x
catch 2012-12-17 22:48:16 +00:00
parent 206598cc42
commit c783542c40
6 changed files with 16 additions and 87 deletions

View File

@ -2,10 +2,10 @@
/** /**
* @file * @file
* Definition of Drupal\views\Plugin\Type\DefaultWizardDeriver. * Contains \Drupal\views\Plugin\Derivative\DefaultWizardDeriver.
*/ */
namespace Drupal\views\Plugin\Type; namespace Drupal\views\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DerivativeInterface; use Drupal\Component\Plugin\Derivative\DerivativeInterface;

View File

@ -1,34 +0,0 @@
<?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\Component\Plugin\Discovery\ProcessDecorator;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
class JoinManager extends PluginManagerBase {
/**
* Constructs a JoinManager object.
*/
public function __construct() {
$this->discovery = new AnnotatedClassDiscovery('views', 'join');
$this->discovery = new AlterDecorator($this->discovery, 'views_plugins_join');
$this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition'));
$this->discovery = new CacheDecorator($this->discovery, 'views:join', 'views_info');
$this->factory = new DefaultFactory($this);
$this->defaults = array(
'module' => 'views',
);
}
}

View File

@ -1,35 +0,0 @@
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\WizardManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
use Drupal\Component\Plugin\Discovery\ProcessDecorator;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
class WizardManager extends PluginManagerBase {
/**
* Constructs a WizardManager object.
*/
public function __construct() {
$this->discovery = new AnnotatedClassDiscovery('views', 'wizard');
$this->discovery = new AlterDecorator($this->discovery, 'views_plugins_wizard');
$this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition'));
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new CacheDecorator($this->discovery, 'views:wizard', 'views_info');
$this->factory = new DefaultFactory($this);
$this->defaults = array(
'module' => 'views',
);
}
}

View File

@ -2,30 +2,36 @@
/** /**
* @file * @file
* Definition of Drupal\views\Plugin\Type\PluginManager. * Contains \Drupal\views\Plugin\ViewsPluginManager.
*/ */
namespace Drupal\views\Plugin\Type; namespace Drupal\views\Plugin;
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Component\Plugin\Discovery\ProcessDecorator; use Drupal\Component\Plugin\Discovery\ProcessDecorator;
use Drupal\Core\Plugin\Discovery\AlterDecorator; use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator; use Drupal\Core\Plugin\Discovery\CacheDecorator;
class PluginManager extends PluginManagerBase { /**
* Plugin type manager for all views plugins.
*/
class ViewsPluginManager extends PluginManagerBase {
/** /**
* Constructs a PluginManager object. * Constructs a ViewsPluginManager object.
*/ */
public function __construct($type) { public function __construct($type) {
$this->discovery = new AnnotatedClassDiscovery('views', $type); $this->discovery = new AnnotatedClassDiscovery('views', $type);
$this->discovery = new AlterDecorator($this->discovery, 'views_plugins_' . $type); $this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition'));
$this->discovery = new AlterDecorator($this->discovery, 'views_plugins_' . $type);
$this->discovery = new CacheDecorator($this->discovery, 'views:' . $type, 'views_info'); $this->discovery = new CacheDecorator($this->discovery, 'views:' . $type, 'views_info');
$this->factory = new DefaultFactory($this); $this->factory = new DefaultFactory($this);
$this->defaults += array( $this->defaults += array(
'parent' => 'parent', 'parent' => 'parent',
'plugin_type' => $type, 'plugin_type' => $type,

View File

@ -12,7 +12,7 @@ use Drupal\Core\Annotation\Plugin;
/** /**
* @Plugin( * @Plugin(
* id = "standard", * id = "standard",
* derivative = "Drupal\views\Plugin\Type\DefaultWizardDeriver" * derivative = "Drupal\views\Plugin\Derivative\DefaultWizardDeriver"
* ) * )
*/ */
class Standard extends WizardPluginBase { class Standard extends WizardPluginBase {

View File

@ -21,17 +21,9 @@ class ViewsBundle extends Bundle {
*/ */
public function build(ContainerBuilder $container) { public function build(ContainerBuilder $container) {
foreach (ViewExecutable::getPluginTypes() as $type) { foreach (ViewExecutable::getPluginTypes() as $type) {
if ($type == 'join') { $container->register("plugin.manager.views.$type", 'Drupal\views\Plugin\ViewsPluginManager')
$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); ->addArgument($type);
} }
} }
}
} }