function _views_create_handler
Instantiate and construct a new handler.
3 calls to _views_create_handler()
- views_get_handler in ./
views.module - Fetch a handler from the data cache.
- views_get_plugin in ./
views.module - Get a handler for a plugin.
- _views_prepare_handler in includes/
handlers.inc - Prepare a handler's data by checking defaults and such.
File
-
includes/
handlers.inc, line 11
Code
function _views_create_handler($definition, $type = 'handler', $handler_type = NULL) {
// @code
// debug('Instantiating handler ' . $definition['handler']);
// @endcode
if (empty($definition['handler'])) {
vpr('_views_create_handler - type: @type - failed: handler has not been provided.', array(
'@type' => isset($handler_type) ? $type . '(handler type: ' . $handler_type . ')' : $type,
));
return;
}
// class_exists will automatically load the code file.
if (!empty($definition['override handler']) && !class_exists($definition['override handler'])) {
vpr('_views_create_handler - loading override handler @type failed: class @override_handler could not be loaded. ' . 'Verify the class file has been registered in the corresponding .info-file (files[]).', array(
'@type' => isset($handler_type) ? $type . '(handler type: ' . $handler_type . ')' : $type,
'@override_handler' => $definition['override handler'],
));
return;
}
if (!class_exists($definition['handler'])) {
vpr('_views_create_handler - loading handler @type failed: class @handler could not be loaded. ' . 'Verify the class file has been registered in the corresponding .info-file (files[]).', array(
'@type' => isset($handler_type) ? $type . '(handler type: ' . $handler_type . ')' : $type,
'@handler' => $definition['handler'],
));
return;
}
if (!empty($definition['override handler'])) {
$handler = new $definition['override handler']();
}
else {
$handler = new $definition['handler']();
}
$handler->set_definition($definition);
if ($type == 'handler') {
$handler->is_handler = TRUE;
$handler->handler_type = $handler_type;
}
else {
$handler->is_plugin = TRUE;
$handler->plugin_type = $type;
$handler->plugin_name = $definition['name'];
}
// Let the handler have something like a constructor.
$handler->construct();
return $handler;
}