Commit d526f0de authored by catch's avatar catch

Issue #2212081 by dawehner: Remove views optional handler handling.

parent 7c226d14
......@@ -321,7 +321,6 @@ display:
hide_alter_empty: true
link_to_node: false
comments: false
optional: true
plugin_id: history_user_timestamp
provider: history
filters:
......@@ -473,7 +472,6 @@ display:
identifier: langcode
remember_roles:
authenticated: authenticated
optional: true
plugin_id: language
provider: language
sorts: { }
......
......@@ -206,7 +206,6 @@ display:
hide_alter_empty: true
link_to_node: false
comments: false
optional: true
plugin_id: history_user_timestamp
provider: history
name:
......
......@@ -330,9 +330,6 @@ views_handler:
provider:
type: string
label: 'Provider'
optional:
type: boolean
label: 'Optional'
views_argument:
type: views_handler
......
......@@ -268,7 +268,7 @@ public function calculateDependencies() {
if (!empty($display['display_options'][$handler_type])) {
foreach ($display['display_options'][$handler_type] as $handler) {
// Add the provider as dependency.
if (isset($handler['provider']) && empty($handler['optional'])) {
if (isset($handler['provider'])) {
$this->addDependency('module', $handler['provider']);
}
// Add the additional dependencies from the handler configuration.
......
......@@ -70,9 +70,6 @@ public function __construct($handler_type, \Traversable $namespaces, ViewsData $
* An associative array representing the handler to be retrieved:
* - table: The name of the table containing the handler.
* - field: The name of the field the handler represents.
* - optional: (optional) Whether or not this handler is optional. If a
* handler is missing and not optional, a debug message will be displayed.
* Defaults to FALSE.
* @param string|null $override
* (optional) Override the actual handler object with this plugin ID. Used for
* aggregation when the handler is redirected to the aggregation handler.
......@@ -83,7 +80,6 @@ public function __construct($handler_type, \Traversable $namespaces, ViewsData $
public function getHandler($item, $override = NULL) {
$table = $item['table'];
$field = $item['field'];
$optional = !empty($item['optional']);
// Get the plugin manager for this type.
$data = $this->viewsData->get($table);
......@@ -119,12 +115,8 @@ public function getHandler($item, $override = NULL) {
}
}
if (!$optional) {
// debug(t("Missing handler: @table @field @type", array('@table' => $table, '@field' => $field, '@type' => $this->handlerType)));
}
// Finally, use the 'broken' handler.
return $this->createInstance('broken', array('optional' => $optional, 'original_configuration' => $item));
return $this->createInstance('broken', array('original_configuration' => $item));
}
/**
......
......@@ -21,7 +21,7 @@ public function adminLabel($short = FALSE) {
$args = array(
'@module' => $this->definition['original_configuration']['provider'],
);
return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args);
return t('Broken/missing handler (Module: @module) …', $args);
}
/**
......@@ -56,12 +56,7 @@ public function query($group_by = FALSE) {
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions().
*/
public function buildOptionsForm(&$form, &$form_state) {
if ($this->isOptional()) {
$description_top = t('The handler for this item is optional. The following details are available:');
}
else {
$description_top = t('The handler for this item is broken or missing. The following details are available:');
}
$description_top = t('The handler for this item is broken or missing. The following details are available:');
$items = array(
t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])),
......
......@@ -85,13 +85,6 @@ abstract class HandlerBase extends PluginBase {
*/
public $relationship = NULL;
/**
* Whether or not this handler is optional.
*
* @var bool
*/
protected $optional = FALSE;
/**
* The module handler.
*
......@@ -112,7 +105,6 @@ abstract class HandlerBase extends PluginBase {
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->is_handler = TRUE;
$this->optional = !empty($configuration['optional']);
}
/**
......@@ -178,15 +170,6 @@ protected function defineOptions() {
return $options;
}
/**
* Returns whether this handler is optional.
*
* @return bool
*/
public function isOptional() {
return $this->optional;
}
/**
* Return a string representing this handler's name in the UI.
*/
......
......@@ -108,21 +108,11 @@ public function testViewsGetHandler() {
$item = array(
'table' => 'table_invalid',
'field' => 'id',
'optional' => FALSE,
);
$this->container->get('plugin.manager.views.filter')->getHandler($item);
$this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
unset($this->lastErrorMessage);
$item = array(
'table' => 'table_invalid',
'field' => 'id',
'optional' => TRUE,
);
$this->container->get('plugin.manager.views.filter')->getHandler($item);
$this->assertFalse($this->lastErrorMessage, "An optional handler does not throw a debug message.");
unset($this->lastErrorMessage);
restore_error_handler();
}
......
base_table: views_test_data
core: '8'
description: ''
status: '1'
display:
default:
display_options:
defaults:
fields: '0'
pager: '0'
pager_options: '0'
sorts: '0'
fields:
id_optional:
field: id_optional
id: id_optional
relationship: none
table: views_test_data
plugin_id: numeric
optional: 1
provider: views
filters:
id_optional:
field: id_optional
id: id_optional
relationship: none
table: views_test_data
plugin_id: numeric
optional: 1
provider: views
arguments:
id_optional:
field: id_optional
id: id_optional
relationship: none
table: views_test_data
plugin_id: numeric
optional: 1
provider: views
sorts:
id_optional:
field: id_optional
id: id_optional
relationship: none
table: views_test_data
plugin_id: numeric
order: ASC
optional: 1
provider: views
relationships:
id_optional:
field: id_optional
id: id_optional
relationship: none
table: views_test_data
plugin_id: numeric
optional: 1
provider: views
header:
id_optional:
field: id_optional
id: id_optional
relationship: none
table: views_test_data
plugin_id: numeric
optional: 1
provider: views
footer:
id_optional:
field: id_optional
id: id_optional
relationship: none
table: views_test_data
plugin_id: numeric
optional: 1
provider: views
empty:
id_optional:
field: id_optional
id: id_optional
relationship: none
table: views_test_data
plugin_id: numeric
optional: 1
provider: views
pager:
options:
offset: '0'
type: none
pager_options: { }
display_plugin: default
display_title: Master
id: default
position: 0
label: 'Test view'
id: test_view_optional
tag: ''
......@@ -23,7 +23,7 @@ class HandlerTest extends UITestBase {
*
* @var array
*/
public static $testViews = array('test_view_empty', 'test_view_broken', 'test_view_optional');
public static $testViews = array('test_view_empty', 'test_view_broken');
/**
* Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition().
......@@ -171,38 +171,4 @@ public function testBrokenHandlers() {
}
}
/**
* Tests optional handlers.
*/
public function testOptionalHandlers() {
$handler_types = ViewExecutable::getHandlerTypes();
foreach ($handler_types as $type => $type_info) {
$this->drupalGet('admin/structure/views/view/test_view_optional/edit');
$href = "admin/structure/views/nojs/handler/test_view_optional/default/$type/id_optional";
$result = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
$this->assertEqual(count($result), 1, String::format('Handler (%type) edit link found.', array('%type' => $type)));
$text = t('Optional handler is missing (Module: @module) …', array('@module' => 'views'));
$this->assertIdentical((string) $result[0], $text, 'Ensure the optional handler link text was found.');
$this->drupalGet($href);
$result = $this->xpath('//h1');
$this->assertTrue(strpos((string) $result[0], $text) !== FALSE, 'Ensure the optional handler title was found.');
$description_args = array(
'@module' => 'views',
'@table' => 'views_test_data',
'@field' => 'id_optional',
);
foreach ($description_args as $token => $value) {
$this->assertNoText($token, String::format('Raw @token token placeholder not found.', array('@token' => $token)));
$this->assertText($value, String::format('Replaced @token value found.', array('@token' => $token)));
}
}
}
}
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