public function DisplayPluginBase::getPlugin in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getPlugin()
Get the instance of a plugin, for example style or row.
Parameters
string $type: The type of the plugin.
Return value
\Drupal\views\Plugin\views\ViewsPluginInterface
Overrides DisplayPluginInterface::getPlugin
16 calls to DisplayPluginBase::getPlugin()
- DisplayPluginBase::access in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php - Determines if the user has access to this display of the view.
- DisplayPluginBase::applyDisplayCacheabilityMetadata in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php - Applies the cacheability of the current display to the given render array.
- DisplayPluginBase::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php - Provide a form to edit options for this plugin.
- DisplayPluginBase::calculateCacheMetadata in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php - Calculates the display's cache metadata by inspecting each handler/plugin.
- DisplayPluginBase::getAllPlugins in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php - Gets all the plugins used by the display.
File
- core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php, line 797
Class
- DisplayPluginBase
- Base class for views display plugins.
Namespace
Drupal\views\Plugin\views\displayCode
public function getPlugin($type) {
// Look up the plugin name to use for this instance.
$options = $this
->getOption($type);
// Return now if no options have been loaded.
if (empty($options) || !isset($options['type'])) {
return;
}
// Query plugins allow specifying a specific query class per base table.
if ($type == 'query') {
$views_data = Views::viewsData()
->get($this->view->storage
->get('base_table'));
$name = isset($views_data['table']['base']['query_id']) ? $views_data['table']['base']['query_id'] : 'views_query';
}
else {
$name = $options['type'];
}
// Plugin instances are stored on the display for re-use.
if (!isset($this->plugins[$type][$name])) {
$plugin = Views::pluginManager($type)
->createInstance($name);
// Initialize the plugin.
$plugin
->init($this->view, $this, $options['options']);
$this->plugins[$type][$name] = $plugin;
}
return $this->plugins[$type][$name];
}