Get the instance of a plugin, for example style or row.
string $type: The type of the plugin.
\Drupal\views\Plugin\views\PluginBase
public function getPlugin($type) {
// Look up the plugin name to use for this instance.
$options = $this
->getOption($type);
$name = $options['type'];
// Query plugins allow specifying a specific query class per base table.
if ($type == 'query') {
$views_data = views_fetch_data($this->view->storage
->get('base_table'));
$name = isset($views_data['table']['base']['query_id']) ? $views_data['table']['base']['query_id'] : '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);
// Initialize the plugin.
$plugin
->init($this->view, $this, $options['options']);
$this->plugins[$type][$name] = $plugin;
}
return $this->plugins[$type][$name];
}