1 views_handler_argument.inc views_handler_argument::get_plugin($type = 'argument default', $name = NULL)

Get the display or row plugin, if it exists.

File

core/modules/views/handlers/views_handler_argument.inc, line 1120
@todo.

Class

views_handler_argument
Base class for arguments.

Code

function get_plugin($type = 'argument default', $name = NULL) {
  $options = array();
  $plugin_name = NULL;
  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_get_plugin($type, $name);
  if ($plugin) {
    // Style plugins expects different parameters as argument related plugins.
    if ($type == 'style') {
      $plugin->init($this->view, $this->view->display_handler->display, $options);
    }
    else {
      $plugin->init($this->view, $this, $options);
    }
    return $plugin;
  }
}