Commit 28c9978f authored by tim.plunkett's avatar tim.plunkett
Browse files

Restore the overridden functionality.

parent 587f8d24
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\views\View; use Drupal\views\View;
use Drupal\views\Join; use Drupal\views\Join;
use Drupal\views\Plugin\Type\ViewsPluginManager; use Drupal\views\Plugin\Type\ViewsPluginManager;
use Drupal\Component\Plugin\Exception\PluginException;
/** /**
* Instantiate and construct a new plugin. * Instantiate and construct a new plugin.
...@@ -32,7 +33,14 @@ function _views_create_plugin($type, $definition) { ...@@ -32,7 +33,14 @@ function _views_create_plugin($type, $definition) {
*/ */
function _views_create_handler($type, $definition) { function _views_create_handler($type, $definition) {
$manager = new ViewsPluginManager($type); $manager = new ViewsPluginManager($type);
$instance = $manager->createInstance($definition['id']); // @todo This is crazy. Find a way to remove the override functionality.
$id = !empty($definition['override handler']) ? $definition['override handler'] : $definition['id'];
try {
$instance = $manager->createInstance($id);
}
catch (PluginException $e) {
$instance = $manager->createInstance($definition['id']);
}
$instance->is_handler = TRUE; $instance->is_handler = TRUE;
$instance->plugin_type = $type; $instance->plugin_type = $type;
......
...@@ -147,6 +147,10 @@ function testviews_get_handler() { ...@@ -147,6 +147,10 @@ function testviews_get_handler() {
$this->assertInstanceHandler($handler, 'views_test', 'name', 'field'); $this->assertInstanceHandler($handler, 'views_test', 'name', 'field');
$handler = views_get_handler('views_test_previous', 'name_previous', 'argument'); $handler = views_get_handler('views_test_previous', 'name_previous', 'argument');
$this->assertInstanceHandler($handler, 'views_test', 'name', 'argument'); $this->assertInstanceHandler($handler, 'views_test', 'name', 'argument');
// Test the override handler feature.
$handler = views_get_handler('views_test', 'job', 'filter', 'string');
$this->assertEqual('Drupal\\views\\Plugin\\views\\filter\\String', get_class($handler));
} }
/** /**
......
...@@ -1224,7 +1224,7 @@ function views_include_handlers($reset = FALSE) { ...@@ -1224,7 +1224,7 @@ function views_include_handlers($reset = FALSE) {
* @return views_handler * @return views_handler
* An instance of a handler object. May be views_handler_broken. * An instance of a handler object. May be views_handler_broken.
*/ */
function views_get_handler($table, $field, $key) { function views_get_handler($table, $field, $key, $override = NULL) {
static $recursion_protection = array(); static $recursion_protection = array();
$data = views_fetch_data($table, FALSE); $data = views_fetch_data($table, FALSE);
...@@ -1255,7 +1255,7 @@ function views_get_handler($table, $field, $key) { ...@@ -1255,7 +1255,7 @@ function views_get_handler($table, $field, $key) {
} }
$recursion_protection[$moved_table][$moved_field] = TRUE; $recursion_protection[$moved_table][$moved_field] = TRUE;
$handler = views_get_handler($moved_table, $moved_field, $key); $handler = views_get_handler($moved_table, $moved_field, $key, $override);
$recursion_protection = array(); $recursion_protection = array();
if ($handler) { if ($handler) {
// store these values so we know what we were originally called. // store these values so we know what we were originally called.
...@@ -1275,6 +1275,10 @@ function views_get_handler($table, $field, $key) { ...@@ -1275,6 +1275,10 @@ function views_get_handler($table, $field, $key) {
$data[$field][$key]['id'] = 'standard'; $data[$field][$key]['id'] = 'standard';
} }
if ($override) {
$data[$field][$key]['override handler'] = $override;
}
$handler = _views_prepare_handler($data[$field][$key], $data, $field, $key); $handler = _views_prepare_handler($data[$field][$key], $data, $field, $key);
} }
......
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