function DisplayPluginBase::getPlugin

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getPlugin()
  2. 10 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getPlugin()
  3. 11.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getPlugin()

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.

... See full list

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\display

Code

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];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.