1 views.module views_get_handler($table, $field, $key, $override = NULL)

Fetch a handler from the data cache.

Parameters

$table: The name of the table this handler is from.

$field: The name of the field this handler is from.

$key: The type of handler. i.e, sort, field, argument, filter, relationship

$override: Override the actual handler object with this class. Used for aggregation when the handler is redirected to the aggregation handler.

Return value

views_handler: An instance of a handler object. May be views_handler_broken.

File

core/modules/views/views.module, line 1065
Primarily Backdrop hooks and global API functions to manipulate views.

Code

function views_get_handler($table, $field, $key, $override = NULL) {
  static $recursion_protection = array();

  $data = views_fetch_data($table, FALSE);
  $handler = NULL;
  views_include('utility');

  // Support old views_data entries conversion.

  // Support conversion on table level.
  if (isset($data['moved to'])) {
    $moved = array($data['moved to'], $field);
  }
  // Support conversion on datafield level.
  if (isset($data[$field]['moved to'])) {
    $moved = $data[$field]['moved to'];
  }
  // Support conversion on handler level.
  if (isset($data[$field][$key]['moved to'])) {
    $moved = $data[$field][$key]['moved to'];
  }

  if (isset($data[$field][$key]) || !empty($moved)) {
    if (!empty($moved)) {
      list($moved_table, $moved_field) = $moved;
      if (!empty($recursion_protection[$moved_table][$moved_field])) {
        // recursion detected!
        return NULL;
      }

      $recursion_protection[$moved_table][$moved_field] = TRUE;
      $handler = views_get_handler($moved_table, $moved_field, $key, $override);
      $recursion_protection = array();
      if ($handler) {
        // store these values so we know what we were originally called.
        $handler->original_table = $table;
        $handler->original_field = $field;
        if (empty($handler->actual_table)) {
          $handler->actual_table = $moved_table;
          $handler->actual_field = $moved_field;
        }
      }
      return $handler;
    }

    // Set up a default handler:
    if (empty($data[$field][$key]['handler'])) {
      $data[$field][$key]['handler'] = 'views_handler_' . $key;
    }

    if ($override) {
      $data[$field][$key]['override handler'] = $override;
    }

    $handler = _views_prepare_handler($data[$field][$key], $data, $field, $key);
  }

  if ($handler) {
    return $handler;
  }

  // Return missing handlers as broken.
  $broken = array(
    'title' => t('Broken handler @table.@field', array('@table' => $table, '@field' => $field)),
    'handler' => 'views_handler_' . $key . '_broken',
    'table' => $table,
    'field' => $field,
  );
  return _views_create_handler($broken, 'handler', $key);
}