Skip to content
Snippets Groups Projects
Commit 9198a460 authored by Tim Plunkett's avatar Tim Plunkett
Browse files

Issue #1796156 by tim.plunkett, dawehner: Further clean-up of getPlugin() for query plugins.

parent 9637ef7d
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -741,27 +741,28 @@ public function usesFields() {
* @return Drupal\views\Plugin\views\PluginBase
*/
public function getPlugin($type) {
// Look up the name to attempt to load it from the static cache.
// Look up the plugin name to use for this instance.
$options = $this->getOption($type);
$name = $options['type'];
if (!isset($this->plugins[$type][$name])) {
// Query plugins allow specifying a specific query class per base table.
if ($type == 'query') {
$views_data = views_fetch_data($this->view->storage->base_table);
if ($type == 'query') {
$name = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query';
}
$name = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query';
}
// Plugin instances are stored on the display for re-use.
if (!isset($this->plugins[$type][$name])) {
$plugin = drupal_container()->get("plugin.manager.views.$type")->createInstance($name);
if ($type != 'query') {
$plugin->init($this->view, $this, $options['options']);
// Initialize the plugin. Query has a unique method signature.
if ($type == 'query') {
$plugin->init($this->view->storage->base_table, $this->view->storage->base_field, $options['options']);
}
else {
if (!isset($this->base_field)) {
$this->view->storage->base_field = !empty($views_data['table']['base']['field']) ? $views_data['table']['base']['field'] : '';
}
$plugin->init($this->view->storage->base_table, $this->view->storage->base_field, $options['options']);
$plugin->init($this->view, $this, $options['options']);
}
$this->plugins[$type][$name] = $plugin;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment