Commit b2970df1 authored by tim.plunkett's avatar tim.plunkett

Remove views_get_plugin_manager() and replace with new ViewsPluginManager().

parent 427ec64d
......@@ -8,7 +8,7 @@
use Drupal\Core\Database\Database;
use Drupal\views\View;
use Drupal\views\Analyzer;
use Drupal\views\Plugin\Type\WizardManager;
use Drupal\views\Plugin\Type\ViewsPluginManager;
/**
* Create an array of Views admin CSS for adding or attaching.
......@@ -381,7 +381,7 @@ function views_ui_add_form($form, &$form_state) {
$wizard_key = $show_form['wizard_key']['#default_value'];
views_include_handlers();
$manager = views_get_plugin_manager('wizard');
$manager = new ViewsPluginManager('wizard');
$info = $manager->getDefinition($wizard_key);
$wizard_instance = $manager->createInstance($wizard_key, $info);
$form = $wizard_instance->build_form($form, $form_state);
......@@ -705,7 +705,7 @@ function views_ui_nojs_submit($form, &$form_state) {
*/
function views_ui_wizard_form_validate($form, &$form_state) {
$wizard = views_ui_get_wizard($form_state['values']['show']['wizard_key']);
$manager = views_get_plugin_manager('wizard');
$manager = new ViewsPluginManager('wizard');
$definition = $manager->getDefinition($wizard['plugin_id']);
$form_state['wizard'] = $wizard;
$form_state['wizard_instance'] = $manager->createInstance($wizard['plugin_id'], $definition);
......
......@@ -5,6 +5,8 @@
* Load Views' data so that it knows what is available to build queries from.
*/
use Drupal\views\Plugin\Type\ViewsPluginManager;
/**
* Fetch Views' data from the cache
*
......@@ -91,13 +93,13 @@ function _views_fetch_plugin_data($type = NULL, $plugin_id = NULL, $reset = FALS
$plugins = array();
$plugin_types = array('access', 'argument_default', 'argument_validator', 'cache', 'display_extender', 'display', 'exposed_form', 'localization', 'pager', 'query', 'row', 'style', 'wizard');
foreach ($plugin_types as $plugin_type) {
$manager = views_get_plugin_manager($plugin_type);
$manager = new ViewsPluginManager($plugin_type);
$plugins[$plugin_type] = $manager->getDefinitions();
}
return $plugins;
}
$manager = views_get_plugin_manager($type);
$manager = new ViewsPluginManager($type);
if (!$plugin_id) {
return $manager->getDefinitions();
......
......@@ -9,8 +9,7 @@
use Drupal\views\View;
use Drupal\views\Join;
use Drupal\views\ViewsObject;
use Drupal\views\Plugin\Type\ViewsPluginManager;
/**
* Instantiate and construct a new plugin.
......@@ -19,7 +18,7 @@
* Figure out what to keep from _views_create_handler.
*/
function _views_create_plugin($type, $plugin_id, $definition) {
$manager = views_get_plugin_manager($type);
$manager = new ViewsPluginManager($type);
$instance = $manager->createInstance($plugin_id);
......@@ -41,7 +40,7 @@ function _views_create_plugin($type, $plugin_id, $definition) {
*/
function _views_create_handler($definition, $type = 'handler', $handler_type = NULL) {
if (!empty($definition['plugin_id'])) {
$manager = views_get_plugin_manager($handler_type);
$manager = new ViewsPluginManager($handler_type);
$handler = $manager->createInstance($definition['plugin_id']);
}
else {
......
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\AccessPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugin\Discovery\ViewsDiscovery;
class AccessPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'access');
$this->factory = new DefaultFactory($this->discovery);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\ArgumentDefaultPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugin\Discovery\ViewsDiscovery;
class ArgumentDefaultPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'argument_default');
$this->factory = new DefaultFactory($this->discovery);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\ArgumentValidatorPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugin\Discovery\ViewsDiscovery;
class ArgumentValidatorPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'argument_validator');
$this->factory = new DefaultFactory($this->discovery);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\CachePluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugin\Discovery\ViewsDiscovery;
class CachePluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'cache');
$this->factory = new DefaultFactory($this->discovery);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\DisplayExtenderPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Views\Plugin\Discovery\ViewsDiscovery;
class DisplayExtenderPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'display_extender');
$this->factory = new DefaultFactory($this->discovery);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\DisplayPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugin\Discovery\ViewsDiscovery;
class DisplayPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'display');
$this->factory = new DefaultFactory($this->discovery);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\ExposedFormPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Views\Plugin\Discovery\ViewsDiscovery;
class ExposedFormPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'exposed_form');
$this->factory = new DefaultFactory($this);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\LocalizationPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Views\Plugin\Discovery\ViewsDiscovery;
class LocalizationPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'localization');
$this->factory = new DefaultFactory($this);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\PagerPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Views\Plugin\Discovery\ViewsDiscovery;
class PagerPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'pager');
$this->factory = new DefaultFactory($this);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\QueryPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Views\Plugin\Discovery\ViewsDiscovery;
class QueryPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'query');
$this->factory = new DefaultFactory($this);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\RowPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Views\Plugin\Discovery\ViewsDiscovery;
class RowPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'row');
$this->factory = new DefaultFactory($this);
}
}
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\StylePluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Views\Plugin\Discovery\ViewsDiscovery;
class StylePluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'style');
$this->factory = new DefaultFactory($this);
}
}
......@@ -2,16 +2,16 @@
/**
* @file
* Definition of Drupal\views\Plugin\Type\HandlerPluginManager.
* Definition of Drupal\views\Plugin\Type\ViewsPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Views\Plugin\Discovery\ViewsDiscovery;
use Drupal\views\Plugin\Discovery\ViewsDiscovery;
class HandlerPluginManager extends PluginManagerBase {
class ViewsPluginManager extends PluginManagerBase {
/**
* The handler type of this plugin manager, for example filter or field.
*
......
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\WizardPluginManager.
*/
namespace Drupal\views\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\views\Plugin\Discovery\ViewsDiscovery;
class WizardPluginManager extends PluginManagerBase {
public function __construct() {
$this->discovery = new ViewsDiscovery('views', 'wizard');
$this->factory = new DefaultFactory($this->discovery);
}
}
......@@ -9,7 +9,7 @@
use Drupal\views\View;
use Drupal\views\Plugin\views\Plugin;
use Drupal\views\Plugin\Type\QueryPluginManager;
use Drupal\views\Plugin\Type\ViewsPluginManager;
/**
* @defgroup views_display_plugins Views display plugins
......@@ -1191,7 +1191,7 @@ function options_summary(&$categories, &$options) {
'desc' => t('Change the title that this display will use.'),
);
$manager = views_get_plugin_manager('style');
$manager = new ViewsPluginManager('style');
$style_plugin = $manager->getDefinition($this->get_option('style_plugin'));
$style_plugin_instance = $this->get_plugin('style');
$style_summary = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin_instance->summary_title();
......@@ -1213,7 +1213,7 @@ function options_summary(&$categories, &$options) {
}
if (!empty($style_plugin['uses_row_plugin'])) {
$manager = views_get_plugin_manager('row');
$manager = new ViewsPluginManager('row');
$row_plugin = $manager->getDefinition($this->get_option('row_plugin'));
$row_plugin_instance = $this->get_plugin('row');
$row_summary = empty($row_plugin['title']) ? t('Missing style plugin') : $row_plugin_instance->summary_title();
......@@ -1727,7 +1727,7 @@ function options_form(&$form, &$form_state) {
}
break;
case 'style_plugin':
$manager = views_get_plugin_manager('style');
$manager = new ViewsPluginManager('style');
$form['#title'] .= t('How should this view be styled');
$form['#help_topic'] = 'style';
$form['style_plugin'] = array(
......
......@@ -8,8 +8,6 @@
namespace Drupal\views;
use Symfony\Component\HttpFoundation\Response;
use Drupal\views\Plugin\Type\QueryPluginManager;
use Drupal\views\Plugin\Type\DisplayPluginManager;
/**
* @defgroup views_objects Objects that represent a View or part of a view
......@@ -917,7 +915,7 @@ function init_query() {
// Create and initialize the query object.
$plugin = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query';
$plugin_type = new QueryPluginManager();
$plugin_type = new ViewsPluginManager('query');
$this->query = $plugin_type->createInstance($plugin);
if (empty($this->query)) {
......
......@@ -12,22 +12,7 @@
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\views\View;
use Drupal\Component\Plugin\PluginManagerInterface;
// @todo: Should views_get_plugin_manager be moved to a ceperate file?
use Drupal\views\Plugin\Type\StylePluginManager;
use Drupal\views\Plugin\Type\DisplayPluginManager;
use Drupal\views\Plugin\Type\AccessPluginManager;
use Drupal\views\Plugin\Type\ArgumentDefaultPluginManager;
use Drupal\views\Plugin\Type\ArgumentValidatorPluginManager;
use Drupal\views\Plugin\Type\CachePluginManager;
use Drupal\views\Plugin\Type\LocalizationPluginManager;
use Drupal\views\Plugin\Type\PagerPluginManager;
use Drupal\views\Plugin\Type\QueryPluginManager;
use Drupal\views\Plugin\Type\RowPluginManager;
use Drupal\views\Plugin\Type\ExposedFormPluginManager;
use Drupal\views\Plugin\Type\HandlerPluginManager;
use Drupal\views\Plugin\Type\DisplayExtenderPluginManager;
use Drupal\views\Plugin\Type\WizardPluginManager;
use Drupal\views\Plugin\Type\ViewsPluginManager;
/**
* Advertise the current views api version
......@@ -1343,7 +1328,7 @@ function views_fetch_plugin_data($type = NULL, $plugin_id = NULL, $reset = FALSE
* A keyed array of in the form of 'base_table' => 'Description'.
*/
function views_fetch_plugin_names($type, $key = NULL, $base = array()) {
$manager = views_get_plugin_manager($type);
$manager = new ViewsPluginManager($type);
$definitions = $manager->getDefinitions();
$plugins = array();
......@@ -1377,76 +1362,13 @@ function views_fetch_plugin_names($type, $key = NULL, $base = array()) {
function views_get_plugin($type, $plugin_id, $reset = FALSE) {
views_include('handlers');
$manager = views_get_plugin_manager($type);
$manager = new ViewsPluginManager($type);
$definition = $manager->getDefinition($plugin_id);
if (!empty($definition)) {
return _views_create_plugin($type, $plugin_id, $definition);
}
}
/**
* Returns the plugin manager used for a certain plugin type.
*
* @param string $type
* The plugin type to use.
*
* @param PluginManagerInterface
*/
function views_get_plugin_manager($type) {
switch ($type) {
case 'display':
$manager = new DisplayPluginManager();
break;
case 'style':
$manager = new StylePluginManager();
break;
case 'row':
$manager = new RowPluginManager();
break;
case 'argument_default':
$manager = new ArgumentDefaultPluginManager();
break;
case 'argument_validator':
$manager = new ArgumentValidatorPluginManager();
break;
case 'access':
$manager = new AccessPluginManager();
break;
case 'query':
$manager = new QueryPluginManager();
break;
case 'cache':
$manager = new CachePluginManager();
break;
// @todo: find out whether to use underscores or spaces.
case 'exposed_form':
$manager = new ExposedFormPluginManager();
break;
case 'pager':
$manager = new PagerPluginManager();
break;
case 'localization':
$manager = new LocalizationPluginManager();
break;
case 'display_extender':
$manager = new DisplayExtenderPluginManager();
break;
case 'wizard':
$manager = new WizardPluginManager();
break;
case 'field':
case 'filter':
case 'argument':
case 'area':
case 'sort':
case 'relationship':
$manager = new HandlerPluginManager($type);
break;
}
return $manager;
}
/**
* Load the current enabled localization plugin.
*
......
......@@ -6,7 +6,7 @@
*/
use Drupal\views\View;
use Drupal\views\Plugin\Type\WizardManager;
use Drupal\views\Plugin\Type\ViewsPluginManager;
/**
* Implements hook_menu().
......@@ -551,7 +551,7 @@ function views_ui_ctools_plugin_directory($module, $plugin) {
*/
function views_ui_get_wizard($wizard_type) {
ctools_include('plugins');
$manager = views_get_plugin_manager('wizard');
$manager = new ViewsPluginManager('wizard');
$wizard = $manager->getDefinition($wizard_type);
// @todo - handle this via an alter hook instead.
if (!$wizard) {
......@@ -577,7 +577,7 @@ function views_ui_get_wizard($wizard_type) {
* An array of arrays with information about all available views wizards.
*/
function views_ui_get_wizards() {
$manager = views_get_plugin_manager('wizard');
$manager = new ViewsPluginManager('wizard');
$wizard_plugins = $manager->getDefinitions();
$wizard_tables = array();
foreach ($wizard_plugins as $name => $info) {
......
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