From b2970df17f8143e80fbb486513de1980f2a5581c Mon Sep 17 00:00:00 2001
From: Tim Plunkett <git@plnktt.com>
Date: Sun, 29 Jul 2012 13:17:53 -0500
Subject: [PATCH] Remove views_get_plugin_manager() and replace with new
 ViewsPluginManager().

---
 includes/admin.inc                            |  6 +-
 includes/cache.inc                            |  6 +-
 includes/handlers.inc                         |  7 +-
 .../views/Plugin/Type/AccessPluginManager.php | 19 -----
 .../Type/ArgumentDefaultPluginManager.php     | 19 -----
 .../Type/ArgumentValidatorPluginManager.php   | 19 -----
 .../views/Plugin/Type/CachePluginManager.php  | 19 -----
 .../Type/DisplayExtenderPluginManager.php     | 19 -----
 .../Plugin/Type/DisplayPluginManager.php      | 19 -----
 .../Plugin/Type/ExposedFormPluginManager.php  | 19 -----
 .../Plugin/Type/LocalizationPluginManager.php | 19 -----
 .../views/Plugin/Type/PagerPluginManager.php  | 19 -----
 .../views/Plugin/Type/QueryPluginManager.php  | 19 -----
 .../views/Plugin/Type/RowPluginManager.php    | 19 -----
 .../views/Plugin/Type/StylePluginManager.php  | 20 -----
 ...uginManager.php => ViewsPluginManager.php} |  6 +-
 .../views/Plugin/Type/WizardPluginManager.php | 20 -----
 .../views/display/DisplayPluginBase.php       |  8 +-
 lib/Drupal/views/View.php                     |  4 +-
 views.module                                  | 84 +------------------
 views_ui.module                               |  6 +-
 21 files changed, 24 insertions(+), 352 deletions(-)
 delete mode 100644 lib/Drupal/views/Plugin/Type/AccessPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/ArgumentDefaultPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/ArgumentValidatorPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/CachePluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/DisplayExtenderPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/DisplayPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/ExposedFormPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/LocalizationPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/PagerPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/QueryPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/RowPluginManager.php
 delete mode 100644 lib/Drupal/views/Plugin/Type/StylePluginManager.php
 rename lib/Drupal/views/Plugin/Type/{HandlerPluginManager.php => ViewsPluginManager.php} (74%)
 delete mode 100644 lib/Drupal/views/Plugin/Type/WizardPluginManager.php

diff --git a/includes/admin.inc b/includes/admin.inc
index 869fab557eef..cf2343d5bc36 100644
--- a/includes/admin.inc
+++ b/includes/admin.inc
@@ -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);
diff --git a/includes/cache.inc b/includes/cache.inc
index 1c554dc780fd..a1711b5232e3 100644
--- a/includes/cache.inc
+++ b/includes/cache.inc
@@ -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();
diff --git a/includes/handlers.inc b/includes/handlers.inc
index 0a1d317959aa..2fc0f9b90a96 100644
--- a/includes/handlers.inc
+++ b/includes/handlers.inc
@@ -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 {
diff --git a/lib/Drupal/views/Plugin/Type/AccessPluginManager.php b/lib/Drupal/views/Plugin/Type/AccessPluginManager.php
deleted file mode 100644
index a6cb79a9e969..000000000000
--- a/lib/Drupal/views/Plugin/Type/AccessPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/ArgumentDefaultPluginManager.php b/lib/Drupal/views/Plugin/Type/ArgumentDefaultPluginManager.php
deleted file mode 100644
index 3b27898479ee..000000000000
--- a/lib/Drupal/views/Plugin/Type/ArgumentDefaultPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/ArgumentValidatorPluginManager.php b/lib/Drupal/views/Plugin/Type/ArgumentValidatorPluginManager.php
deleted file mode 100644
index a2c473f9223e..000000000000
--- a/lib/Drupal/views/Plugin/Type/ArgumentValidatorPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/CachePluginManager.php b/lib/Drupal/views/Plugin/Type/CachePluginManager.php
deleted file mode 100644
index d48e0b0ca0b5..000000000000
--- a/lib/Drupal/views/Plugin/Type/CachePluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/DisplayExtenderPluginManager.php b/lib/Drupal/views/Plugin/Type/DisplayExtenderPluginManager.php
deleted file mode 100644
index c31ce8a7988d..000000000000
--- a/lib/Drupal/views/Plugin/Type/DisplayExtenderPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/DisplayPluginManager.php b/lib/Drupal/views/Plugin/Type/DisplayPluginManager.php
deleted file mode 100644
index af406b4f6111..000000000000
--- a/lib/Drupal/views/Plugin/Type/DisplayPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/ExposedFormPluginManager.php b/lib/Drupal/views/Plugin/Type/ExposedFormPluginManager.php
deleted file mode 100644
index fd2d49573453..000000000000
--- a/lib/Drupal/views/Plugin/Type/ExposedFormPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/LocalizationPluginManager.php b/lib/Drupal/views/Plugin/Type/LocalizationPluginManager.php
deleted file mode 100644
index 846313e08986..000000000000
--- a/lib/Drupal/views/Plugin/Type/LocalizationPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/PagerPluginManager.php b/lib/Drupal/views/Plugin/Type/PagerPluginManager.php
deleted file mode 100644
index 03ae37bbe351..000000000000
--- a/lib/Drupal/views/Plugin/Type/PagerPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/QueryPluginManager.php b/lib/Drupal/views/Plugin/Type/QueryPluginManager.php
deleted file mode 100644
index 6ff3afd00e10..000000000000
--- a/lib/Drupal/views/Plugin/Type/QueryPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/RowPluginManager.php b/lib/Drupal/views/Plugin/Type/RowPluginManager.php
deleted file mode 100644
index ccd86fd44025..000000000000
--- a/lib/Drupal/views/Plugin/Type/RowPluginManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/StylePluginManager.php b/lib/Drupal/views/Plugin/Type/StylePluginManager.php
deleted file mode 100644
index e752ab0a6870..000000000000
--- a/lib/Drupal/views/Plugin/Type/StylePluginManager.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?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);
-  }
-}
diff --git a/lib/Drupal/views/Plugin/Type/HandlerPluginManager.php b/lib/Drupal/views/Plugin/Type/ViewsPluginManager.php
similarity index 74%
rename from lib/Drupal/views/Plugin/Type/HandlerPluginManager.php
rename to lib/Drupal/views/Plugin/Type/ViewsPluginManager.php
index a345c11415f4..553893e708fa 100644
--- a/lib/Drupal/views/Plugin/Type/HandlerPluginManager.php
+++ b/lib/Drupal/views/Plugin/Type/ViewsPluginManager.php
@@ -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.
    *
diff --git a/lib/Drupal/views/Plugin/Type/WizardPluginManager.php b/lib/Drupal/views/Plugin/Type/WizardPluginManager.php
deleted file mode 100644
index 94762fd58f12..000000000000
--- a/lib/Drupal/views/Plugin/Type/WizardPluginManager.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?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);
-  }
-}
-
diff --git a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
index 6572cdf74660..dbfd70984f83 100644
--- a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
+++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
@@ -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(
diff --git a/lib/Drupal/views/View.php b/lib/Drupal/views/View.php
index 4d783f08e63b..e1d790748203 100644
--- a/lib/Drupal/views/View.php
+++ b/lib/Drupal/views/View.php
@@ -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)) {
diff --git a/views.module b/views.module
index c7200b2ff9e1..d3c5a82292b2 100644
--- a/views.module
+++ b/views.module
@@ -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.
  *
diff --git a/views_ui.module b/views_ui.module
index 7119fc4d6967..738c791c0219 100644
--- a/views_ui.module
+++ b/views_ui.module
@@ -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) {
-- 
GitLab