You are here

public function ViewExecutable::getHandlers in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::getHandlers()

Gets an array of handler instances for the current display.

Parameters

string $type: The type of handlers to retrieve.

string $display_id: (optional) A specific display machine name to use. If NULL, the current display will be used.

Return value

array An array of handler instances of a given type for this display.

File

core/modules/views/src/ViewExecutable.php, line 2104
Contains \Drupal\views\ViewExecutable.

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function getHandlers($type, $display_id = NULL) {
  $old_display_id = !empty($this->current_display) ? $this->current_display : 'default';
  $this
    ->setDisplay($display_id);
  if (!isset($display_id)) {
    $display_id = $this->current_display;
  }

  // Get info about the types so we can get the right data.
  $types = static::getHandlerTypes();
  $handlers = $this->displayHandlers
    ->get($display_id)
    ->getOption($types[$type]['plural']);

  // Restore initial display id (if any) or set to 'default'.
  if ($display_id != $old_display_id) {
    $this
      ->setDisplay($old_display_id);
  }
  return $handlers;
}