Commit e235776e authored by webchick's avatar webchick

Issue #2016953 by dawehner, damiankloip, tim.plunkett: Indicate when an...

Issue #2016953 by dawehner, damiankloip, tim.plunkett: Indicate when an optional handler is missing, that it is not 'broken'.
parent 09fd48a2
......@@ -279,6 +279,7 @@ display:
text: Translate
optional: '1'
plugin_id: content_translation_link
provider: content_translation
dropbutton:
id: dropbutton
table: views
......
......@@ -77,7 +77,7 @@ public function __construct($handler_type, \Traversable $namespaces, ViewsData $
public function getHandler($item, $override = NULL) {
$table = $item['table'];
$field = $item['field'];
$optional = isset($item['optional']) ? $item['optional'] : FALSE;
$optional = !empty($item['optional']);
// Get the plugin manager for this type.
$data = $this->viewsData->get($table);
......@@ -118,7 +118,7 @@ public function getHandler($item, $override = NULL) {
}
// Finally, use the 'broken' handler.
return $this->createInstance('broken');
return $this->createInstance('broken', array('optional' => $optional, 'original_configuration' => $item));
}
}
......@@ -76,12 +76,20 @@ abstract class HandlerBase extends PluginBase {
*/
public $relationship = NULL;
/**
* Whether or not this handler is optional.
*
* @var bool
*/
protected $optional = FALSE;
/**
* Constructs a Handler object.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->is_handler = TRUE;
$this->optional = !empty($configuration['optional']);
}
/**
......@@ -151,6 +159,15 @@ 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.
*/
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Plugin\views\area;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ViewExecutable;
/**
* A special handler to take the place of missing or broken handlers.
......@@ -19,7 +20,10 @@
class Broken extends AreaPluginBase {
public function adminLabel($short = FALSE) {
return t('Broken/missing handler');
$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);
}
public function defineOptions() { return array(); }
......@@ -32,9 +36,41 @@ public function render($empty = FALSE) {
// Simply render nothing by returning an empty render array.
return array();
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, &$form_state) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
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:');
}
$items = array(
t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])),
t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])),
t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])),
);
$description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.');
$form['description'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('form-item', 'description'),
),
'description_top' => array(
'#markup' => '<p>' . $description_top . '</p>',
),
'detail_list' => array(
'#theme' => 'item_list',
'#items' => $items,
),
'description_bottom' => array(
'#markup' => '<p>' . $description_bottom . '</p>',
),
);
}
......
......@@ -19,15 +19,50 @@
class Broken extends ArgumentPluginBase {
public function adminLabel($short = FALSE) {
return t('Broken/missing handler');
$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);
}
public function defineOptions() { return array(); }
public function ensureMyTable() { /* No table to ensure! */ }
public function query($group_by = FALSE) { /* No query to run */ }
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, &$form_state) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
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:');
}
$items = array(
t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])),
t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])),
t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])),
);
$description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.');
$form['description'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('form-item', 'description'),
),
'description_top' => array(
'#markup' => '<p>' . $description_top . '</p>',
),
'detail_list' => array(
'#theme' => 'item_list',
'#items' => $items,
),
'description_bottom' => array(
'#markup' => '<p>' . $description_bottom . '</p>',
),
);
}
......
......@@ -19,15 +19,50 @@
class Broken extends FieldPluginBase {
public function adminLabel($short = FALSE) {
return t('Broken/missing handler');
$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);
}
public function defineOptions() { return array(); }
public function ensureMyTable() { /* No table to ensure! */ }
public function query($group_by = FALSE) { /* No query to run */ }
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, &$form_state) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
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:');
}
$items = array(
t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])),
t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])),
t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])),
);
$description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.');
$form['description'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('form-item', 'description'),
),
'description_top' => array(
'#markup' => '<p>' . $description_top . '</p>',
),
'detail_list' => array(
'#theme' => 'item_list',
'#items' => $items,
),
'description_bottom' => array(
'#markup' => '<p>' . $description_bottom . '</p>',
),
);
}
......
......@@ -27,15 +27,50 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
}
public function adminLabel($short = FALSE) {
return t('Broken/missing handler');
$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);
}
public function defineOptions() { return array(); }
public function ensureMyTable() { /* No table to ensure! */ }
public function query($group_by = FALSE) { /* No query to run */ }
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, &$form_state) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
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:');
}
$items = array(
t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])),
t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])),
t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])),
);
$description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.');
$form['description'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('form-item', 'description'),
),
'description_top' => array(
'#markup' => '<p>' . $description_top . '</p>',
),
'detail_list' => array(
'#theme' => 'item_list',
'#items' => $items,
),
'description_bottom' => array(
'#markup' => '<p>' . $description_bottom . '</p>',
),
);
}
......
......@@ -19,15 +19,50 @@
class Broken extends RelationshipPluginBase {
public function adminLabel($short = FALSE) {
return t('Broken/missing handler');
$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);
}
public function defineOptions() { return array(); }
public function ensureMyTable() { /* No table to ensure! */ }
public function query() { /* No query to run */ }
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, &$form_state) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
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:');
}
$items = array(
t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])),
t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])),
t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])),
);
$description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.');
$form['description'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('form-item', 'description'),
),
'description_top' => array(
'#markup' => '<p>' . $description_top . '</p>',
),
'detail_list' => array(
'#theme' => 'item_list',
'#items' => $items,
),
'description_bottom' => array(
'#markup' => '<p>' . $description_bottom . '</p>',
),
);
}
......
......@@ -19,15 +19,50 @@
class Broken extends SortPluginBase {
public function adminLabel($short = FALSE) {
return t('Broken/missing handler');
$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);
}
public function defineOptions() { return array(); }
public function ensureMyTable() { /* No table to ensure! */ }
public function query($group_by = FALSE) { /* No query to run */ }
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, &$form_state) {
$form['markup'] = array(
'#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
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:');
}
$items = array(
t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])),
t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])),
t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])),
);
$description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.');
$form['description'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('form-item', 'description'),
),
'description_top' => array(
'#markup' => '<p>' . $description_top . '</p>',
),
'detail_list' => array(
'#theme' => 'item_list',
'#items' => $items,
),
'description_bottom' => array(
'#markup' => '<p>' . $description_bottom . '</p>',
),
);
}
......
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_broken:
field: id_broken
id: id_broken
relationship: none
table: views_test_data
plugin_id: numeric
provider: views
filters:
id_broken:
field: id_broken
id: id_broken
relationship: none
table: views_test_data
plugin_id: numeric
provider: views
arguments:
id_broken:
field: id_broken
id: id_broken
relationship: none
table: views_test_data
plugin_id: numeric
provider: views
sorts:
id_broken:
field: id_broken
id: id_broken
relationship: none
table: views_test_data
plugin_id: numeric
order: ASC
provider: views
relationships:
id_broken:
field: id_broken
id: id_broken
relationship: none
table: views_test_data
plugin_id: numeric
provider: views
header:
id_broken:
field: id_broken
id: id_broken
relationship: none
table: views_test_data
plugin_id: numeric
provider: views
footer:
id_broken:
field: id_broken
id: id_broken
relationship: none
table: views_test_data
plugin_id: numeric
provider: views
empty:
id_broken:
field: id_broken
id: id_broken
relationship: none
table: views_test_data
plugin_id: numeric
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_broken
tag: ''
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'