Commit 64002e87 authored by tim.plunkett's avatar tim.plunkett
Browse files

Bring _views_create_handler() and _views_create_plugin() closer together.

parent 3b2195d9
......@@ -13,50 +13,39 @@
/**
* Instantiate and construct a new plugin.
*
* @todo
* Figure out what to keep from _views_create_handler.
*/
function _views_create_plugin($type, $plugin_id, $definition) {
function _views_create_plugin($type, $definition) {
$manager = new ViewsPluginManager($type);
$instance = $manager->createInstance($plugin_id);
$instance = $manager->createInstance($definition['plugin_id']);
$instance->is_plugin = TRUE;
$instance->plugin_type = $type;
$instance->plugin_name = $plugin_id;
$instance->plugin_name = $definition['plugin_id'];
$instance->set_definition($definition);
// Let the handler have something like a constructor.
$instance->construct();
return $instance;
}
/**
* Instantiate and construct a new handler
*/
function _views_create_handler($definition, $type = 'handler', $handler_type = NULL) {
if (!empty($definition['plugin_id'])) {
$manager = new ViewsPluginManager($handler_type);
$handler = $manager->createInstance($definition['plugin_id']);
}
else {
// @todo: remove this else, once all instances got converted.
$handler = new $definition['handler']($definition, $definition['handler']);
}
function _views_create_handler($type, $definition) {
$manager = new ViewsPluginManager($type);
$instance = $manager->createInstance($definition['plugin_id']);
$handler->set_definition($definition);
$instance->is_handler = TRUE;
$instance->handler_type = $type;
$handler->is_handler = TRUE;
$handler->handler_type = $handler_type;
$instance->set_definition($definition);
// let the handler have something like a constructor.
$handler->construct();
$instance->construct();
return $handler;
return $instance;
}
/**
......@@ -76,7 +65,7 @@ function _views_prepare_handler($definition, $data, $field, $type) {
}
}
return _views_create_handler($definition, 'handler', $type);
return _views_create_handler($type, $definition);
}
/**
......
......@@ -1290,7 +1290,7 @@ function views_get_handler($table, $field, $key, $override = NULL) {
'table' => $table,
'field' => $field,
);
return _views_create_handler($broken, 'handler', $key);
return _views_create_handler($key, $broken);
}
/**
......@@ -1369,7 +1369,7 @@ function views_get_plugin($type, $plugin_id, $reset = FALSE) {
$manager = new ViewsPluginManager($type);
$definition = $manager->getDefinition($plugin_id);
if (!empty($definition)) {
return _views_create_plugin($type, $plugin_id, $definition);
return _views_create_plugin($type, $definition);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment