You are here

public function DisplayPluginBase::getPlugin in Views (for Drupal 7) 8.3

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

12 calls to DisplayPluginBase::getPlugin()
DisplayPluginBase::access in lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
Determine if the user has access to this display of the view.
DisplayPluginBase::buildOptionsForm in lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
Provide the default form for setting options.
DisplayPluginBase::isPagerEnabled in lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
Whether the display is using a pager or not.
DisplayPluginBase::optionsSummary in lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
Provide the default summary for options in the views UI.
DisplayPluginBase::preExecute in lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
Set up any variables on the view prior to execution. These are separated from execute because they are extremely common and unlikely to be overridden on an individual display.

... See full list

File

lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php, line 750
Definition of Drupal\views\Plugin\views\display\DisplayPluginBase.

Class

DisplayPluginBase
The default display plugin handler. Display plugins handle options and basic mechanisms for different output methods.

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);
  $name = $options['type'];

  // Query plugins allow specifying a specific query class per base table.
  if ($type == 'query') {
    $views_data = views_fetch_data($this->view->storage->base_table);
    $name = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query';
  }

  // Plugin instances are stored on the display for re-use.
  if (!isset($this->plugins[$type][$name])) {
    $plugin = drupal_container()
      ->get("plugin.manager.views.{$type}")
      ->createInstance($name);

    // Initialize the plugin. Query has a unique method signature.
    if ($type == 'query') {
      $plugin
        ->init($this->view->storage->base_table, $this->view->storage->base_field, $options['options']);
    }
    else {
      $plugin
        ->init($this->view, $this, $options['options']);
    }
    $this->plugins[$type][$name] = $plugin;
  }
  return $this->plugins[$type][$name];
}