ViewExecutable::setHandler

public ViewExecutable::setHandler($display_id, $type, $id, $item)

Sets the configuration of a handler instance on a given display.

Parameters

string $display_id: The machine name of the display.

string $type: The type of handler being set.

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

array|null $item: An array of configuration for a handler, or NULL to remove this instance.

See also

set_item_option()

File

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

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function setHandler($display_id, $type, $id, $item) {
  // 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']);
  if (isset($item)) {
    $fields[$id] = $item;
  }

  // Store.
  $this->displayHandlers->get($display_id)->setOption($types[$type]['plural'], $fields);
}
doc_Drupal
2016-10-29 09:54:27
Comments
Leave a Comment

Please login to continue.