diff --git a/includes/admin.inc b/includes/admin.inc index b69331e65f2255604f799446a73dfbfb3865ff62..2314812266b3beaaceca5a6fbc1644d5ee465031 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -9,7 +9,6 @@ use Drupal\views\TempStore\UserTempStore; use Drupal\views\View; use Drupal\views\Analyzer; -use Drupal\views\Plugin\Type\ViewsPluginManager; use Drupal\views\Plugin\views\wizard\WizardException; /** @@ -348,9 +347,9 @@ function views_ui_add_form($form, &$form_state) { $wizard_key = $show_form['wizard_key']['#default_value']; views_include_handlers(); - $manager = new ViewsPluginManager('wizard'); - $info = $manager->getDefinition($wizard_key); - $wizard_instance = $manager->createInstance($wizard_key, $info); + $info = views_get_plugin_definition('wizard', $wizard_key); + $wizard_instance = views_get_plugin_instance($wizard_key, $info); + $form = $wizard_instance->build_form($form, $form_state); $form['save'] = array( @@ -656,10 +655,9 @@ 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 = new ViewsPluginManager('wizard'); - $definition = $manager->getDefinition($wizard['id']); + $definition = views_get_plugin_definition('wizard', $wizard['id']); $form_state['wizard'] = $wizard; - $form_state['wizard_instance'] = $manager->createInstance($wizard['id'], $definition); + $form_state['wizard_instance'] = views_get_plugin_instance($wizard['id'], $definition); $errors = $form_state['wizard_instance']->validate($form, $form_state); foreach ($errors as $name => $message) { form_set_error($name, $message); @@ -1521,7 +1519,7 @@ function views_ui_get_display_tab_details($view, $display) { '#attributes' => array('id' => 'edit-display-settings-details'), ); - $plugin = views_fetch_plugin_data('display', $view->display[$display->id]->display_plugin); + $plugin = views_get_plugin_definition('display', $view->display[$display->id]->display_plugin); // The following is for display purposes only. We need to determine if there is more than one button and wrap // the buttons in a .ctools-dropbutton class if more than one is present. Otherwise, we'll just wrap the // actions in the .ctools-button class. diff --git a/includes/cache.inc b/includes/cache.inc index ff636f9460cd39b91497cbd1f0dceac639cc3d41..e5beeb79d9d7353a8fb88bf081598d71d0b5d4ab 100644 --- a/includes/cache.inc +++ b/includes/cache.inc @@ -5,8 +5,6 @@ * 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 * @@ -85,30 +83,6 @@ function _views_data_process_entity_types(&$data) { } } -/** - * Fetch the plugin data from cache. - */ -function _views_fetch_plugin_data($type = NULL, $id = NULL, $reset = FALSE) { - if (!$type && !$id) { - $plugins = array(); - $plugin_types = array('access', 'area', 'argument', 'argument_default', 'argument_validator', 'cache', 'display_extender', 'display', 'exposed_form', 'field', 'filter', 'join', 'localization', 'pager', 'query', 'relationship', 'row', 'sort', 'style', 'wizard'); - foreach ($plugin_types as $plugin_type) { - $manager = new ViewsPluginManager($plugin_type); - $plugins[$plugin_type] = $manager->getDefinitions(); - } - return $plugins; - } - - $manager = new ViewsPluginManager($type); - - if (!$id) { - return $manager->getDefinitions(); - } - else { - return $manager->getDefinition($id); - } -} - /** * Set a cached item in the views cache. * diff --git a/includes/handlers.inc b/includes/handlers.inc index ddfab3c15f77d85c7541dbec0292edd4522f86f3..dc9b3bd79c09b3efee146d4ca5c5594d22ff1063 100644 --- a/includes/handlers.inc +++ b/includes/handlers.inc @@ -6,51 +6,8 @@ */ use Drupal\Core\Database\Database; -use Drupal\views\Plugin\Type\ViewsPluginManager; use Drupal\Component\Plugin\Exception\PluginException; -/** - * Instantiate and construct a new plugin. - */ -function _views_create_plugin($type, $definition) { - $manager = new ViewsPluginManager($type); - $instance = $manager->createInstance($definition['id']); - - $instance->is_plugin = TRUE; - $instance->plugin_type = $type; - $instance->setDefinition($definition); - - // Let the handler have something like a constructor. - $instance->construct(); - - return $instance; -} - -/** - * Instantiate and construct a new handler - */ -function _views_create_handler($type, $definition) { - $manager = new ViewsPluginManager($type); - // @todo This is crazy. Find a way to remove the override functionality. - $id = !empty($definition['override handler']) ? $definition['override handler'] : $definition['id']; - try { - $instance = $manager->createInstance($id); - } - catch (PluginException $e) { - $instance = $manager->createInstance($definition['id']); - } - - $instance->is_handler = TRUE; - $instance->plugin_type = $type; - - $instance->setDefinition($definition); - - // let the handler have something like a constructor. - $instance->construct(); - - return $instance; -} - /** * Prepare a handler's data by checking defaults and such. */ @@ -71,6 +28,24 @@ function _views_prepare_handler($definition, $data, $field, $type) { return _views_create_handler($type, $definition); } +/** + * Get a handler for a plugin + * + * @param string $type + * The plugin type like access or display. + * @param string $id + * The name of the plugin like standard. + * + * @return views_plugin + * + * The created plugin object. + */ +function _views_create_handler($type, $definition) { + $manager = new ViewsPluginManager($type); + $plugin = $manager->createHandlerFromDefinition($definition); + return $plugin; +} + /** * Fetch a handler to join one table to a primary table from the data cache */ @@ -84,7 +59,7 @@ function views_get_table_join($table, $base_table) { else { $id = 'standard'; } - $handler = views_get_join($id); + $handler = views_get_plugin_instance('join', $id); // Fill in some easy defaults $handler->definition = $h; diff --git a/lib/Drupal/views/Plugin/Type/ViewsPluginManager.php b/lib/Drupal/views/Plugin/Type/ViewsPluginManager.php index 3cca741b6f24204c13f675714400de1a0cd78e04..3a0ad7d0a33543e9914bdfcf032d510bdeaf87e0 100644 --- a/lib/Drupal/views/Plugin/Type/ViewsPluginManager.php +++ b/lib/Drupal/views/Plugin/Type/ViewsPluginManager.php @@ -73,4 +73,53 @@ public function processDefinition(&$definition, $plugin_id) { ); } + /** + * Creates a plugin from an id. + */ + public function createPluginFromId($id) { + $definition = $this->getDefinition($id); + if (!empty($definition)) { + $plugin = $this->createPluginFromDefinition($defintion); + return $plugin; + } + } + + /** + * Creates a plugin from a definition. + */ + public function createPluginFromDefinition($definition) { + $instance = $this->createInstance($definition['id']); + $instance->is_plugin = TRUE; + $instance->plugin_type = $this->$type; + $instance->setDefinition($definition); + + // Let the handler have something like a constructor. + $instance->construct(); + + return $instance; + } + + /** + * Creates a handler from a definition. + */ + public function createHandlerFromDefinition($definition) { + // @todo This is crazy. Find a way to remove the override functionality. + $id = !empty($definition['override handler']) ? $definition['override handler'] : $definition['id']; + try { + $instance = $this->createInstance($id); + } + catch (PluginException $e) { + $instance = $this->createInstance($definition['id']); + } + + $instance->is_handler = TRUE; + $instance->plugin_type = $this->$type; + $instance->setDefinition($definition); + + // let the handler have something like a constructor. + $instance->construct(); + + return $instance; + } + } diff --git a/lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php b/lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php index 01760edd7ae7a5a046127563ae02cadcbddac5e7..aa4fdfdbed7e9c330818ecd10f9eae387a0ab330 100644 --- a/lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php +++ b/lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php @@ -184,7 +184,7 @@ function list_form(&$form, &$form_state) { ); $displays = array(); - foreach (views_fetch_plugin_data('display') as $id => $info) { + foreach (views_get_plugin_definitions('display') as $id => $info) { if (!empty($info['admin'])) { $displays[$id] = $info['admin']; } diff --git a/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php b/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php index 218bff8b5f2dcd1c338d104dbca6b4ea94292a76..cb2f7876d9cf1c4130d8d36f907f60be4395b1a0 100644 --- a/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php +++ b/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php @@ -303,7 +303,7 @@ public function buildOptionsForm(&$form, &$form_state) { ); $validate_types = array('none' => t('- Basic validation -')); - $plugins = views_fetch_plugin_data('argument_validator'); + $plugins = views_get_plugin_definitions('argument_validator'); foreach ($plugins as $id => $info) { if (!empty($info['no_ui'])) { continue; @@ -498,7 +498,7 @@ function default_actions($which = NULL) { * default action is set to provide default argument. */ function default_argument_form(&$form, &$form_state) { - $plugins = views_fetch_plugin_data('argument_default'); + $plugins = views_get_plugin_definitions('argument_default'); $options = array(); $form['default_argument_skip_url'] = array( @@ -562,7 +562,7 @@ function default_argument_form(&$form, &$form_state) { * default action is set to display one. */ function default_summary_form(&$form, &$form_state) { - $style_plugins = views_fetch_plugin_data('style'); + $style_plugins = views_get_plugin_definitions('style'); $summary_plugins = array(); $format_options = array(); foreach ($style_plugins as $key => $plugin) { diff --git a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index b8ab779d1fc2624793a1c0fcd7a373c6f7ef0d3e..f7c5b05dcf78736dcb51f8c779ae61ceab0bd089 100644 --- a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -9,7 +9,6 @@ use Drupal\views\View; use Drupal\views\Plugin\views\PluginBase; -use Drupal\views\Plugin\Type\ViewsPluginManager; /** * @defgroup views_display_plugins Views display plugins @@ -818,8 +817,7 @@ public function getPlugin($type = 'style', $name = NULL) { $plugin = views_get_plugin($type, $name); } else { - $plugin_type = new ViewsPluginManager('query'); - $plugin = $plugin_type->createInstance($name); + $plugin = views_get_plugin_instance('query', $name); } if (!$plugin) { @@ -1116,9 +1114,8 @@ public function optionsSummary(&$categories, &$options) { 'desc' => t('Change the title that this display will use.'), ); - $manager = new ViewsPluginManager('style'); $name = $this->getOption('style_plugin'); - $style_plugin = $manager->getDefinition($name); + $style_plugin = views_get_plugin_definition('style', $name); $style_plugin_instance = $this->getPlugin('style', $name); $style_summary = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin_instance->summaryTitle(); $style_title = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin_instance->pluginTitle(); @@ -1139,9 +1136,8 @@ public function optionsSummary(&$categories, &$options) { } if ($style_plugin_instance->usesRowPlugin()) { - $manager = new ViewsPluginManager('row'); $name = $this->getOption('row_plugin'); - $row_plugin = $manager->getDefinition($name); + $row_plugin = views_get_plugin_definition('row', $name); $row_plugin_instance = $this->getPlugin('row', $name); $row_summary = empty($row_plugin['title']) ? t('Missing style plugin') : $row_plugin_instance->summaryTitle(); $row_title = empty($row_plugin['title']) ? t('Missing style plugin') : $row_plugin_instance->pluginTitle(); @@ -1639,7 +1635,6 @@ public function buildOptionsForm(&$form, &$form_state) { } break; case 'style_plugin': - $manager = new ViewsPluginManager('style'); $form['#title'] .= t('How should this view be styled'); $form['style_plugin'] = array( '#type' => 'radios', diff --git a/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php b/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php index 26e2a06439f92f6eaf8075e2f359c41441cb8e08..074f8f277de47aaddfeb2e8c43af42de5911e87c 100644 --- a/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php +++ b/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php @@ -377,7 +377,7 @@ public function query() { else { $id = 'subquery'; } - $join = views_get_join($id); + $join = views_get_plugin_instance('join', $id); $join->definition = $def; $join->construct(); diff --git a/lib/Drupal/views/Plugin/views/relationship/RelationshipPluginBase.php b/lib/Drupal/views/Plugin/views/relationship/RelationshipPluginBase.php index 43a31c5e3d3c72b6588af3cfc1ea345007535466..5fd0f58c80002e4f91af2de0e69a876f18932caa 100644 --- a/lib/Drupal/views/Plugin/views/relationship/RelationshipPluginBase.php +++ b/lib/Drupal/views/Plugin/views/relationship/RelationshipPluginBase.php @@ -138,7 +138,7 @@ public function query() { else { $id = 'standard'; } - $join = views_get_join($id); + $join = views_get_plugin_instance('join', $id); $join->definition = $def; $join->options = $this->options; diff --git a/lib/Drupal/views/Plugin/views/sort/MenuHierarchy.php b/lib/Drupal/views/Plugin/views/sort/MenuHierarchy.php index 71d4de017403e3fdf5cc1fac89a50d7cc0894060..e2bbb0ff3a6573084b378b2a99207319e9e43e80 100644 --- a/lib/Drupal/views/Plugin/views/sort/MenuHierarchy.php +++ b/lib/Drupal/views/Plugin/views/sort/MenuHierarchy.php @@ -46,7 +46,7 @@ public function query() { $max_depth = isset($this->definition['max depth']) ? $this->definition['max depth'] : MENU_MAX_DEPTH; for ($i = 1; $i <= $max_depth; ++$i) { if ($this->options['sort_within_level']) { - $join = views_get_join(); + $join = views_get_plugin_instance('join'); $join->construct('menu_links', $this->table_alias, $this->field . $i, 'mlid'); $menu_links = $this->query->add_table('menu_links', NULL, $join); $this->query->add_orderby($menu_links, 'weight', $this->options['order']); diff --git a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index a2e39be7b93a5ef834cc2a5aef03def78a39d9c7..6144ec16bb815d00d8df26e53b1326a79c084230 100644 --- a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -9,7 +9,6 @@ use Drupal\views\View; use Drupal\views\Plugin\views\wizard\WizardInterface; -use Drupal\views\Plugin\Type\ViewsPluginManager; /** * Provides the interface and base class for Views Wizard plugins. @@ -749,8 +748,7 @@ protected function default_display_filters_user($form, $form_state) { $table_data = views_fetch_data($table); // If the 'in' operator is being used, map the values to an array. $handler = $table_data[$bundle_key]['filter']['id']; - $plugin_manager = new ViewsPluginManager('filter'); - $handler_definition = $plugin_manager->getDefinition($handler); + $handler_definition = views_get_plugin_definition('filter', $handler); if ($handler == 'in_operator' || is_subclass_of($handler_definition['class'], 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) { $value = drupal_map_assoc(array($form_state['values']['show']['type'])); } diff --git a/lib/Drupal/views/Tests/Plugin/AccessTest.php b/lib/Drupal/views/Tests/Plugin/AccessTest.php index 71d4d1978e174e1e97dceeb58b826c151e6c77cf..226f8f25c8c603118becec5680720437e1d58c31 100644 --- a/lib/Drupal/views/Tests/Plugin/AccessTest.php +++ b/lib/Drupal/views/Tests/Plugin/AccessTest.php @@ -32,8 +32,8 @@ protected function setUp() { $this->normal_role = $this->drupalCreateRole(array()); $this->normal_user = $this->drupalCreateUser(array('views_test test permission')); $this->normal_user->roles[$this->normal_role] = $this->normal_role; - // Reset the plugin data. - views_fetch_plugin_data(NULL, NULL, TRUE); + // @todo when all the plugin information is cached make a reset function and + // call it here. } /** diff --git a/lib/Drupal/views/Tests/TranslatableTest.php b/lib/Drupal/views/Tests/TranslatableTest.php index bd016f9dc4a887a623ca31d6574df2833dfc6b59..8c8e2f8c38253e3e8690369ed7ce1f9709ee5823 100644 --- a/lib/Drupal/views/Tests/TranslatableTest.php +++ b/lib/Drupal/views/Tests/TranslatableTest.php @@ -32,7 +32,8 @@ protected function setUp() { config('views.settings')->set('localization_plugin', 'test_localization')->save(); // Reset the plugin data. - views_fetch_plugin_data(NULL, NULL, TRUE); + // @todo when all the plugin information is cached make a reset function and + // call it here. $this->strings = array( 'Master1', 'Apply1', diff --git a/lib/Drupal/views/View.php b/lib/Drupal/views/View.php index fe7c7e1ba204485ecb6b4d58315c54c70030efcd..edf5455b7bb275a66fca54dadec6c15c2952abd0 100644 --- a/lib/Drupal/views/View.php +++ b/lib/Drupal/views/View.php @@ -8,7 +8,6 @@ namespace Drupal\views; use Symfony\Component\HttpFoundation\Response; -use Drupal\views\Plugin\Type\ViewsPluginManager; /** * @defgroup views_objects Objects that represent a View or part of a view @@ -1047,8 +1046,7 @@ public function initQuery() { // 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 ViewsPluginManager('query'); - $this->query = $plugin_type->createInstance($plugin); + $this->query = views_get_plugin_instance('query', $plugin); if (empty($this->query)) { return FALSE; diff --git a/lib/Drupal/views/ViewStorage.php b/lib/Drupal/views/ViewStorage.php index bc909d3f8faf83dfcdec3c2909757d43bd2f01eb..0da217ceb0b991c25e9ce0b74f23d8a4321e4a84 100644 --- a/lib/Drupal/views/ViewStorage.php +++ b/lib/Drupal/views/ViewStorage.php @@ -63,7 +63,7 @@ public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL) { return FALSE; } - $plugin = views_fetch_plugin_data('display', $plugin_id); + $plugin = views_get_plugin_definition('display', $plugin_id); if (empty($plugin)) { $plugin['title'] = t('Broken'); } diff --git a/lib/Views/comment/Plugin/views/field/NcsLastCommentName.php b/lib/Views/comment/Plugin/views/field/NcsLastCommentName.php index bce8143c052dcc9dbf0772a9ceecff09dd27d207..b43ab8007a385c1bee8427ba172c230ad802195a 100644 --- a/lib/Views/comment/Plugin/views/field/NcsLastCommentName.php +++ b/lib/Views/comment/Plugin/views/field/NcsLastCommentName.php @@ -27,7 +27,7 @@ public function query() { // have to join in a specially related user table. $this->ensureMyTable(); // join 'users' to this table via vid - $join = views_get_join(); + $join = views_get_plugin_instance('join'); $join->construct('users', $this->table_alias, 'last_comment_uid', 'uid'); $join->extra = array(array('field' => 'uid', 'operator' => '!=', 'value' => '0')); diff --git a/lib/Views/comment/Plugin/views/sort/NcsLastCommentName.php b/lib/Views/comment/Plugin/views/sort/NcsLastCommentName.php index 54b806cf510e05f7bd69b14ffa8c0ac68816e38b..ef2657f0233ca90b6a4f97e07790697fc37585f3 100644 --- a/lib/Views/comment/Plugin/views/sort/NcsLastCommentName.php +++ b/lib/Views/comment/Plugin/views/sort/NcsLastCommentName.php @@ -25,7 +25,7 @@ class NcsLastCommentName extends SortPluginBase { public function query() { $this->ensureMyTable(); - $join = views_get_join(); + $join = views_get_plugin_instance('join'); $join->construct('users', $this->table_alias, 'last_comment_uid', 'uid'); // @todo this might be safer if we had an ensure_relationship rather than guessing diff --git a/lib/Views/field/Plugin/views/relationship/EntityReverse.php b/lib/Views/field/Plugin/views/relationship/EntityReverse.php index a02519142dc96119c8a67d74a8dcc96c00e3d2b2..3b396b385d31eaea8d047d4e39dce1fcb7273914 100644 --- a/lib/Views/field/Plugin/views/relationship/EntityReverse.php +++ b/lib/Views/field/Plugin/views/relationship/EntityReverse.php @@ -58,7 +58,7 @@ public function query() { else { $id = 'standard'; } - $first_join = views_get_join($id); + $first_join = views_get_plugin_instance('join', $id); $first_join->definition = $first; $first_join->construct(); @@ -85,7 +85,7 @@ public function query() { else { $id = 'standard'; } - $second_join = views_get_join($id); + $second_join = views_get_plugin_instance('join', $id); $second_join->definition = $second; $second_join->construct(); $second_join->adjusted = TRUE; diff --git a/lib/Views/search/Plugin/views/argument/Search.php b/lib/Views/search/Plugin/views/argument/Search.php index 73171d8007e604ee082c5062f05c592c9644f32a..0e438fd5d6fc54e4a7930e43f6974e8e68c80dee 100644 --- a/lib/Views/search/Plugin/views/argument/Search.php +++ b/lib/Views/search/Plugin/views/argument/Search.php @@ -62,7 +62,7 @@ public function query($group_by = FALSE) { $search_condition = db_and(); // Create a new join to relate the 'search_total' table to our current 'search_index' table. - $join = views_get_join(); + $join = views_get_plugin_instance('join'); $join->construct('search_total', $search_index, 'word', 'word'); $search_total = $this->query->add_relationship('search_total', $join, $search_index); diff --git a/lib/Views/search/Plugin/views/filter/Search.php b/lib/Views/search/Plugin/views/filter/Search.php index b6eb15020cf8ca85d77ef96558e7378149b3df53..ce0a77669d6bac915861223010b7ddc6ee54eaca 100644 --- a/lib/Views/search/Plugin/views/filter/Search.php +++ b/lib/Views/search/Plugin/views/filter/Search.php @@ -142,7 +142,7 @@ public function query() { $search_condition = db_and(); // Create a new join to relate the 'serach_total' table to our current 'search_index' table. - $join = views_get_join(); + $join = views_get_plugin_instance('join'); $join->construct('search_total', $search_index, 'word', 'word'); $search_total = $this->query->add_relationship('search_total', $join, $search_index); diff --git a/lib/Views/taxonomy/Plugin/views/relationship/NodeTermData.php b/lib/Views/taxonomy/Plugin/views/relationship/NodeTermData.php index bfa29f819e3f526492fce184193387a491d5ae53..4cd0aba6ee4e0e0f441d7eb75f6b946e269f7961 100644 --- a/lib/Views/taxonomy/Plugin/views/relationship/NodeTermData.php +++ b/lib/Views/taxonomy/Plugin/views/relationship/NodeTermData.php @@ -92,7 +92,7 @@ public function query() { $def['table formula'] = $query; } - $join = views_get_join('standard'); + $join = views_get_plugin_instance('join'); $join->definition = $def; $join->construct(); diff --git a/lib/Views/translation/Plugin/views/relationship/Translation.php b/lib/Views/translation/Plugin/views/relationship/Translation.php index 21675b0f2c4dc602f174356e46542f30c91d845d..95980c4500d53b05ac841e0e08618def42714827 100644 --- a/lib/Views/translation/Plugin/views/relationship/Translation.php +++ b/lib/Views/translation/Plugin/views/relationship/Translation.php @@ -101,7 +101,7 @@ public function query() { else { $id = 'standard'; } - $join = views_get_join($id); + $join = views_get_plugin_instance('join', $id); $join->definition = $def; $join->construct(); diff --git a/views.module b/views.module index 65d882cb2b83b5d2e5d45f42bf9e8211869af1e0..e02353486d53b3ab3284d3e9e4c4014e05e05857 100644 --- a/views.module +++ b/views.module @@ -186,7 +186,7 @@ function views_theme($existing, $type, $theme, $path) { 'variables' => array('view' => NULL, 'grouping' => NULL, 'grouping_level' => NULL, 'rows' => NULL, 'title' => NULL), ); - $plugins = views_fetch_plugin_data(); + $plugins = views_get_plugin_definitions(); // Register theme functions for all style plugins foreach ($plugins as $type => $info) { @@ -346,7 +346,7 @@ function _views_find_module_templates($cache, $path) { * keyed by machine name. */ function views_plugin_list() { - $plugin_data = views_fetch_plugin_data(); + $plugin_data = views_get_plugin_definitions(); $plugins = array(); foreach (views_get_enabled_views() as $view) { foreach ($view->display as $display_id => $display) { @@ -910,7 +910,7 @@ function views_add_contextual_links(&$render_element, $location, $view, $display // Also do not do anything if the display plugin has not defined any // contextual links that are intended to be displayed in the requested // location. - $plugin = views_fetch_plugin_data('display', $view->display[$display_id]->display_plugin); + $plugin = views_get_plugin_defintion('display', $view->display[$display_id]->display_plugin); // If contextual_links_locations are not set, provide a sane default. (To // avoid displaying any contextual links at all, a display plugin can still // set 'contextual_links_locations' to, e.g., {""}.) @@ -1277,7 +1277,7 @@ function views_include_handlers($reset = FALSE) { function views_get_handler($table, $field, $key, $override = NULL) { static $recursion_protection = array(); - $data = views_fetch_data($table, FALSE); + $data = views_get_plugin_definitions($table); $handler = NULL; views_include('handlers'); @@ -1358,14 +1358,6 @@ function views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) { // ----------------------------------------------------------------------- // Views plugin functions -/** - * Fetch the plugin data from cache. - */ -function views_fetch_plugin_data($type = NULL, $id = NULL, $reset = FALSE) { - views_include('cache'); - return _views_fetch_plugin_data($type, $id, $reset); -} - /** * Fetch a list of all base tables available * @@ -1381,8 +1373,7 @@ function views_fetch_plugin_data($type = NULL, $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 = new ViewsPluginManager($type); - $definitions = $manager->getDefinitions(); + $definitions = views_get_plugin_definitions($type); $plugins = array(); foreach ($definitions as $id => $plugin) { @@ -1422,14 +1413,33 @@ function views_fetch_plugin_names($type, $key = NULL, $base = array()) { * * The created plugin object. */ -function views_get_plugin($type, $id, $reset = FALSE) { - views_include('handlers'); - +function views_get_plugin($type, $id) { $manager = new ViewsPluginManager($type); - $definition = $manager->getDefinition($id); - if (!empty($definition)) { - return _views_create_plugin($type, $definition); + $manager->createPluginFromId($id); +} + +/** + * Gets all the views plugin definitions + */ +function views_get_plugin_definitions($type = FALSE) { + $plugins = array(); + $plugin_types = $type ? array($type) : array('access', 'area', 'argument', 'argument_default', 'argument_validator', 'cache', 'display_extender', 'display', 'exposed_form', 'field', 'filter', 'join', 'localization', 'pager', 'query', 'relationship', 'row', 'sort', 'style', 'wizard'); + foreach ($plugin_types as $plugin_type) { + $manager = new ViewsPluginManager($plugin_type); + $plugins[$plugin_type] = $manager->getDefinitions(); } + if ($type) { + return $plugins[$type]; + } + return $plugins; +} + +/** + * Gets the plugin definition from a plugin type with a specific id. + */ +function views_get_plugin_definition($type, $id) { + $manager = new ViewsPluginManager($type); + return $manager->getDefintion($id); } /** @@ -1440,9 +1450,9 @@ function views_get_plugin($type, $id, $reset = FALSE) { * * @return Drupal\views\Plugin\views\join\JoinPluginBase */ -function views_get_join($plugin_id = 'standard') { - $manager = new ViewsPluginManager('join'); - return $manager->createInstance($plugin_id); +function views_get_plugin_instance($type, $plugin_id = 'standard', array $configuration = array()) { + $manager = new ViewsPluginManager($type); + return $manager->createInstance($plugin_id, $configuration); } /** @@ -1547,7 +1557,7 @@ function views_get_applicable_views($type) { // Loop on array keys because something seems to muck with $view->display // a bit in PHP4. foreach (array_keys($view->display) as $id) { - $plugin = views_fetch_plugin_data('display', $view->display[$id]->display_plugin); + $plugin = views_get_plugin_defintion('display', $view->display[$id]->display_plugin); if (!empty($plugin[$type])) { // This view uses_hook_menu. Clone it so that different handlers // don't trip over each other, and add it to the list. diff --git a/views_ui.module b/views_ui.module index 3eaad344e9392b3b79339dd55ddb30b0691320df..74c081ab8d8c1a8c466655bc7a9d3128c64a8e40 100644 --- a/views_ui.module +++ b/views_ui.module @@ -6,7 +6,6 @@ */ use Drupal\views\View; -use Drupal\views\Plugin\Type\ViewsPluginManager; /** * Implements hook_menu(). @@ -553,8 +552,7 @@ function views_ui_ctools_plugin_directory($module, $plugin) { * An array with information about the requested wizard type. */ function views_ui_get_wizard($wizard_type) { - $manager = new ViewsPluginManager('wizard'); - $wizard = $manager->getDefinition($wizard_type); + $wizard_plugins = views_get_plugin_definition('wizard', $wizard_type); // @todo - handle this via an alter hook instead. if (!$wizard) { // Must be a base table using the default wizard plugin. @@ -575,8 +573,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 = new ViewsPluginManager('wizard'); - $wizard_plugins = $manager->getDefinitions(); + $wizard_plugins = views_get_plugin_definitions('wizard'); $wizard_tables = array(); foreach ($wizard_plugins as $name => $info) { $wizard_tables[$info['base_table']] = TRUE; @@ -627,9 +624,7 @@ function views_ui_ctools_plugin_type() { } function views_ui_get_form_wizard_instance($wizard) { - $manager = new ViewsPluginManager('wizard'); - $instance = $manager->createInstance($wizard['name']); - return $instance; + return views_get_plugin_instance('wizard', $wizard['name']); } /**