public function ViewExecutable::setItem

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()

1 call to ViewExecutable::setItem()
ViewExecutable::setItemOption in drupal/core/modules/views/lib/Drupal/views/ViewExecutable.php
Sets an option on a handler instance.

File

drupal/core/modules/views/lib/Drupal/views/ViewExecutable.php, line 2190
Definition of Drupal\views\ViewExecutable.

Class

ViewExecutable
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Namespace

Drupal\views

Code

public function setItem($display_id, $type, $id, $item) {

  // Get info about the types so we can get the right data.
  $types = $this::viewsHandlerTypes();

  // Initialize the display.
  $this
    ->setDisplay($display_id);

  // Get the existing configuration.
  $fields = $this->displayHandlers[$display_id]
    ->getOption($types[$type]['plural']);
  if (isset($item)) {
    $fields[$id] = $item;
  }
  else {
    unset($fields[$id]);
  }

  // Store.
  $this->displayHandlers[$display_id]
    ->setOption($types[$type]['plural'], $fields);
}