Issue #2206809 by damiankloip: Convert broken handlers to use a trait.
parent
a66e9586ec
commit
9065f499af
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\views\Plugin\views\BrokenHandlerTrait.
|
||||
*/
|
||||
|
||||
namespace Drupal\views\Plugin\views;
|
||||
|
||||
/**
|
||||
* A Trait for Views broken handlers.
|
||||
*/
|
||||
trait BrokenHandlerTrait {
|
||||
|
||||
/**
|
||||
* Returns this handlers name in the UI.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions().
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* The option definition for this handler.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\PluginBase::defineOptions().
|
||||
*/
|
||||
public function defineOptions() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the main table for this handler is in the query. This is used
|
||||
* a lot.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\HandlerBase::ensureMyTable().
|
||||
*/
|
||||
public function ensureMyTable() {
|
||||
// No table to ensure.
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the views query.
|
||||
*/
|
||||
public function query($group_by = FALSE) {
|
||||
/* No query to run */
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a form to edit options for this plugin.
|
||||
*
|
||||
* @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:');
|
||||
}
|
||||
|
||||
$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>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the handler is considered 'broken'.
|
||||
*
|
||||
* This means it's a placeholder used when a handler can't be found.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\HandlerBase::broken().
|
||||
*/
|
||||
public function broken() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\views\Plugin\views\area;
|
||||
|
||||
use Drupal\views\Plugin\views\BrokenHandlerTrait;
|
||||
|
||||
/**
|
||||
* A special handler to take the place of missing or broken handlers.
|
||||
*
|
||||
|
@ -15,30 +17,7 @@ namespace Drupal\views\Plugin\views\area;
|
|||
* @PluginID("broken")
|
||||
*/
|
||||
class Broken extends AreaPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defineOptions() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function ensureMyTable() {
|
||||
// No table to ensure.
|
||||
}
|
||||
use BrokenHandlerTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -48,48 +27,4 @@ class Broken extends AreaPluginBase {
|
|||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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:');
|
||||
}
|
||||
|
||||
$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>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function broken() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\views\Plugin\views\argument;
|
||||
|
||||
use Drupal\views\Plugin\views\BrokenHandlerTrait;
|
||||
|
||||
/**
|
||||
* A special handler to take the place of missing or broken handlers.
|
||||
*
|
||||
|
@ -15,58 +17,6 @@ namespace Drupal\views\Plugin\views\argument;
|
|||
* @PluginID("broken")
|
||||
*/
|
||||
class Broken extends ArgumentPluginBase {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
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>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
*/
|
||||
public function broken() { return TRUE; }
|
||||
use BrokenHandlerTrait;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\views\Plugin\views\field;
|
||||
|
||||
use Drupal\views\Plugin\views\BrokenHandlerTrait;
|
||||
|
||||
/**
|
||||
* A special handler to take the place of missing or broken handlers.
|
||||
*
|
||||
|
@ -15,58 +17,6 @@ namespace Drupal\views\Plugin\views\field;
|
|||
* @PluginID("broken")
|
||||
*/
|
||||
class Broken extends FieldPluginBase {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
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>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
*/
|
||||
public function broken() { return TRUE; }
|
||||
use BrokenHandlerTrait;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\views\Plugin\views\filter;
|
||||
|
||||
use Drupal\views\Plugin\views\BrokenHandlerTrait;
|
||||
use Drupal\views\Plugin\views\display\DisplayPluginBase;
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
||||
|
@ -18,64 +19,12 @@ use Drupal\views\ViewExecutable;
|
|||
* @PluginID("broken")
|
||||
*/
|
||||
class Broken extends FilterPluginBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\views\Plugin\views\filter\FilterPluginBase::init().
|
||||
*/
|
||||
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public function defineOptions() { return array(); }
|
||||
public function ensureMyTable() { /* No table to ensure! */ }
|
||||
public function query($group_by = FALSE) { /* No query to run */ }
|
||||
use BrokenHandlerTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildOptionsForm(&$form, &$form_state) {
|
||||
if ($this->isOptional()) {
|
||||
$description_top = t('The handler for this item is optional. The following details are available:');
|
||||
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
|
||||
}
|
||||
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>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
*/
|
||||
public function broken() { return TRUE; }
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\views\Plugin\views\relationship;
|
||||
|
||||
use Drupal\views\Plugin\views\BrokenHandlerTrait;
|
||||
|
||||
/**
|
||||
* A special handler to take the place of missing or broken handlers.
|
||||
*
|
||||
|
@ -15,80 +17,6 @@ namespace Drupal\views\Plugin\views\relationship;
|
|||
* @PluginID("broken")
|
||||
*/
|
||||
class Broken extends RelationshipPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function defineOptions() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function ensureMyTable() {
|
||||
// No table to ensure.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// No query to run.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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:');
|
||||
}
|
||||
|
||||
$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>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function broken() {
|
||||
return TRUE;
|
||||
}
|
||||
use BrokenHandlerTrait;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\views\Plugin\views\sort;
|
||||
|
||||
use Drupal\views\Plugin\views\BrokenHandlerTrait;
|
||||
|
||||
/**
|
||||
* A special handler to take the place of missing or broken handlers.
|
||||
*
|
||||
|
@ -15,58 +17,6 @@ namespace Drupal\views\Plugin\views\sort;
|
|||
* @PluginID("broken")
|
||||
*/
|
||||
class Broken extends SortPluginBase {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
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>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
*/
|
||||
public function broken() { return TRUE; }
|
||||
use BrokenHandlerTrait;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue