Commit 9198a460 authored by tim.plunkett's avatar tim.plunkett

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

parent 9637ef7d
......@@ -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;
}
......
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