Adds an instance of a handler to the view.
Items may be fields, filters, sort criteria, or arguments.
string $display_id: The machine name of the display.
string $type: The type of handler being added.
string $table: The name of the table this handler is from.
string $field: The name of the field this handler is from.
array $options: (optional) Extra options for this instance. Defaults to an empty array.
string $id: (optional) A unique ID for this handler instance. Defaults to NULL, in which case one will be generated.
string The unique ID for this handler instance.
public function addItem($display_id, $type, $table, $field, $options = array(), $id = NULL) {
$types = $this::viewsHandlerTypes();
$this
->setDisplay($display_id);
$fields = $this->displayHandlers[$display_id]
->getOption($types[$type]['plural']);
if (empty($id)) {
$id = $this
->generateItemId($field, $fields);
}
// If the desired type is not found, use the original value directly.
$handler_type = !empty($types[$type]['type']) ? $types[$type]['type'] : $type;
// @todo This variable is never used.
$handler = views_get_handler($table, $field, $handler_type);
$fields[$id] = array(
'id' => $id,
'table' => $table,
'field' => $field,
) + $options;
$this->displayHandlers[$display_id]
->setOption($types[$type]['plural'], $fields);
return $id;
}