function views_get_handler
Fetch a handler from the data cache.
Parameters
string $table: The name of the table this handler is from.
string $field: The name of the field this handler is from.
string $key: The type of handler. i.e, sort, field, argument, filter, relationship.
mixed $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.
15 calls to views_get_handler()
- ViewsHandlersTest::test_views_break_phrase in tests/
views_handlers.test - Tests views_break_phrase function.
- ViewsHandlersTest::test_views_break_phrase_string in tests/
views_handlers.test - Tests views_break_phrase_string function.
- ViewsModuleTest::testViewsGetHandler in tests/
views_module.test - Tests views_get_handler().
- views_handler_sort_group_by_numeric::init in handlers/
views_handler_sort_group_by_numeric.inc - Init the handler with necessary data.
- views_plugin_display::export_handler in plugins/
views_plugin_display.inc - Special method to export items that have handlers.
File
-
./
views.module, line 1347
Code
function views_get_handler($table, $field, $key, $override = NULL) {
static $recursion_protection = array();
$data = views_fetch_data($table, FALSE);
$handler = NULL;
views_include('handlers');
// 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;
}
// DEBUG -- identify missing handlers.
$placeholders = array(
'@table' => $table,
'@field' => $field,
'@key' => $key,
);
vpr("Missing handler: @table @field @key", $placeholders);
$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);
}