function _views_create_handler

Same name in other branches
  1. 7.x-3.x includes/handlers.inc \_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 10

Code

function _views_create_handler($definition, $type = 'handler', $handler_type = NULL) {
    //  vpr('Instantiating handler ' . $definition['handler']);
    if (empty($definition['handler'])) {
        return;
    }
    if (!empty($definition['override handler']) && !class_exists($definition['override handler'], FALSE) && !views_include_handler($definition['override handler'], $definition, $type)) {
        return;
    }
    if (!class_exists($definition['handler'], FALSE) && !views_include_handler($definition['handler'], $definition, $type)) {
        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;
    }
    // let the handler have something like a constructor.
    $handler->construct();
    return $handler;
}