public function ArgumentPluginBase::getPlugin

Get the display or row plugin, if it exists.

8 calls to ArgumentPluginBase::getPlugin()

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php, line 1034
Definition of Drupal\views\Plugin\views\argument\ArgumentPluginBase.

Class

ArgumentPluginBase
Base class for arguments.

Namespace

Drupal\views\Plugin\views\argument

Code

public function getPlugin($type = 'argument_default', $name = NULL) {
  $options = array();
  switch ($type) {
    case 'argument_default':
      $plugin_name = $this->options['default_argument_type'];
      $options_name = 'default_argument_options';
      break;
    case 'argument_validator':
      $plugin_name = $this->options['validate']['type'];
      $options_name = 'validate_options';
      break;
    case 'style':
      $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;
  }
}