Skip to content
Snippets Groups Projects
Commit 783657ec authored by Bram Goffings's avatar Bram Goffings Committed by Tim Plunkett
Browse files

fixed some views module tests

parent b0918738
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -20,9 +20,7 @@ function _views_create_plugin($type, $definition) {
$instance->is_plugin = TRUE;
$instance->plugin_type = $type;
$instance->plugin_name = $definition['id'];
$instance->set_definition($definition);
$instance->setDefinition($definition);
// Let the handler have something like a constructor.
$instance->construct();
......@@ -38,9 +36,9 @@ function _views_create_handler($type, $definition) {
$instance = $manager->createInstance($definition['id']);
$instance->is_handler = TRUE;
$instance->handler_type = $type;
$instance->plugin_type = $type;
$instance->set_definition($definition);
$instance->setDefinition($definition);
// let the handler have something like a constructor.
$instance->construct();
......
......@@ -35,9 +35,9 @@ function init(&$view, &$options) {
}
$types = View::views_object_types();
$plural = $this->handler_type;
if (isset($types[$this->handler_type]['plural'])) {
$plural = $types[$this->handler_type]['plural'];
$plural = $this->plugin_type;
if (isset($types[$this->plugin_type]['plural'])) {
$plural = $types[$this->plugin_type]['plural'];
}
if ($this->view->display_handler->is_defaulted($plural)) {
$display_id = 'default';
......@@ -45,7 +45,7 @@ function init(&$view, &$options) {
$this->localization_keys = array(
$display_id,
$this->handler_type,
$this->plugin_type,
$options['table'],
$options['id']
);
......
......@@ -11,10 +11,6 @@
use Drupal\Component\Plugin\PluginBase;
abstract class Plugin extends PluginBase {
public function __construct(array $configuration, $id) {
$this->configuration = $configuration;
$this->id = $id;
}
/**
* Except for displays, options for the object will be held here.
......@@ -35,6 +31,19 @@ public function __construct(array $configuration, $id) {
*/
var $definition;
/**
* The plugin type of this plugin, for example style or query.
*/
var $plugin_type = NULL;
/**
* Constructs a Plugin object.
*/
public function __construct(array $configuration, $plugin_id) {
$this->configuration = $configuration;
$this->plugin_id = $plugin_id;
}
/**
* Information about options for all kinds of purposes will be held here.
* @code
......@@ -185,8 +194,11 @@ function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $c
/**
* Let the handler know what its full definition is.
*/
function set_definition($definition) {
function setDefinition($definition) {
$this->definition = $definition;
if (isset($definition['id'])) {
$this->plugin_id = $definition['id'];
}
if (isset($definition['field'])) {
$this->real_field = $definition['field'];
}
......@@ -352,16 +364,6 @@ function unpack_translatable(&$translatable, $storage, $option, $definition, $pa
}
}
/**
* The plugin type of this plugin, for example style or query.
*/
var $plugin_type = NULL;
/**
* The plugin name of this plugin, for example table or full.
*/
var $plugin_name = NULL;
/**
* Init will be called after construct, when the plugin is attached to a
* view and a display.
......
......@@ -111,7 +111,7 @@ function testviews_get_handler() {
$types = array('field', 'area', 'filter');
foreach ($types as $type) {
$handler = views_get_handler($this->randomName(), $this->randomName(), $type);
$this->assertEqual('views_handler_' . $type . '_broken', get_class($handler), t('Make sure that a broken handler of type: @type are created', array('@type' => $type)));
$this->assertEqual('Drupal\views\Plugin\views\\' . $type . '\Broken', get_class($handler), t('Make sure that a broken handler of type: @type are created', array('@type' => $type)));
}
$views_data = $this->viewsData();
......@@ -160,6 +160,6 @@ function assertInstanceHandler($handler, $table, $field, $id) {
$table_data = views_fetch_data($table);
$field_data = $table_data[$field][$id];
$this->assertEqual($field_data['handler'], get_class($handler));
$this->assertEqual($field_data['id'], $handler->getPluginId());
}
}
......@@ -50,7 +50,7 @@
* - Create the initial handler; at this time it is not yet attached to a
* view. It is here that you can set basic defaults if needed, but there
* will be no knowledge of the environment yet.
* - handler->set_definition()
* - handler->setDefinition()
* - Set the data from hook_views_data() relevant to the handler.
* - handler->init()
* - Attach the handler to a view, and usually provides the options from the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment