function ViewExecutable::removeHandler

Same name in other branches
  1. 9 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::removeHandler()
  2. 10 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::removeHandler()
  3. 11.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::removeHandler()

Removes configuration for a handler instance on a given display.

Parameters

string $display_id: The machine name of the display.

string $type: The type of handler being removed.

string $id: The ID of the handler being removed.

File

core/modules/views/src/ViewExecutable.php, line 2337

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function removeHandler($display_id, $type, $id) {
    // Get info about the types so we can get the right data.
    $types = static::getHandlerTypes();
    // Initialize the display.
    $this->setDisplay($display_id);
    // Get the existing configuration.
    $fields = $this->displayHandlers
        ->get($display_id)
        ->getOption($types[$type]['plural']);
    // Unset the item.
    unset($fields[$id]);
    // Store.
    $this->displayHandlers
        ->get($display_id)
        ->setOption($types[$type]['plural'], $fields);
}

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