function ArgumentPluginBase::getPlugin

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

Get the display or row plugin, if it exists.

12 calls to ArgumentPluginBase::getPlugin()
ArgumentPluginBase::buildOptionsForm in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
Provide a form to edit options for this plugin.
ArgumentPluginBase::calculateDependencies in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
Calculates dependencies for the configured plugin.
ArgumentPluginBase::defaultArgumentForm in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
Provides a form for selecting the default argument.
ArgumentPluginBase::defaultSummaryForm in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
Provides a form for selecting summary options.
ArgumentPluginBase::getCacheContexts in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
The cache contexts associated with this object.

... See full list

File

core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php, line 1100

Class

ArgumentPluginBase
Base class for argument (contextual filter) handler plugins.

Namespace

Drupal\views\Plugin\views\argument

Code

public function getPlugin($type = 'argument_default', $name = NULL) {
    $options = [];
    switch ($type) {
        case 'argument_default':
            if (!isset($this->options['default_argument_type'])) {
                return;
            }
            $plugin_name = $this->options['default_argument_type'];
            $options_name = 'default_argument_options';
            break;
        case 'argument_validator':
            if (!isset($this->options['validate']['type'])) {
                return;
            }
            $plugin_name = $this->options['validate']['type'];
            $options_name = 'validate_options';
            break;
        case 'style':
            if (!isset($this->options['summary']['format'])) {
                return;
            }
            $plugin_name = $this->options['summary']['format'];
            $options_name = 'summary_options';
    }
    if (!$name) {
        $name = $plugin_name;
    }
    // we only fetch the options if we're fetching the plugin actually
    // in use.
    if ($name == $plugin_name) {
        $options = $this->options[$options_name] ?? [];
    }
    $plugin = Views::pluginManager($type)->createInstance($name);
    if ($plugin) {
        $plugin->init($this->view, $this->displayHandler, $options);
        if ($type !== 'style') {
            // It's an argument_default/argument_validate plugin, so set the argument.
            $plugin->setArgument($this);
        }
        return $plugin;
    }
}

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