diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/BrokenHandlerTrait.php b/core/modules/views/lib/Drupal/views/Plugin/views/BrokenHandlerTrait.php new file mode 100644 index 00000000000..e1623f750f0 --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/views/BrokenHandlerTrait.php @@ -0,0 +1,103 @@ + $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' => '

' . $description_top . '

', + ), + 'detail_list' => array( + '#theme' => 'item_list', + '#items' => $items, + ), + 'description_bottom' => array( + '#markup' => '

' . $description_bottom . '

', + ), + ); + } + + /** + * 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; + } + +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php index dff668bfa6d..6a0967c56f3 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php @@ -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' => '

' . $description_top . '

', - ), - 'detail_list' => array( - '#theme' => 'item_list', - '#items' => $items, - ), - 'description_bottom' => array( - '#markup' => '

' . $description_bottom . '

', - ), - ); - } - - /** - * {@inheritdoc} - */ - public function broken() { - return TRUE; - } - } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/Broken.php index 9e82624d1b6..f9f90acf000 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/Broken.php @@ -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' => '

' . $description_top . '

', - ), - 'detail_list' => array( - '#theme' => 'item_list', - '#items' => $items, - ), - 'description_bottom' => array( - '#markup' => '

' . $description_bottom . '

', - ), - ); - } - - /** - * Determine if the handler is considered 'broken' - */ - public function broken() { return TRUE; } + use BrokenHandlerTrait; } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/field/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/Broken.php index 062927f447c..c76431e2578 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/field/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/Broken.php @@ -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' => '

' . $description_top . '

', - ), - 'detail_list' => array( - '#theme' => 'item_list', - '#items' => $items, - ), - 'description_bottom' => array( - '#markup' => '

' . $description_bottom . '

', - ), - ); - } - - /** - * Determine if the handler is considered 'broken' - */ - public function broken() { return TRUE; } + use BrokenHandlerTrait; } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/filter/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/filter/Broken.php index e4b1333f70a..2a4abcf7423 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/filter/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/Broken.php @@ -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:'); - } - 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' => '

' . $description_top . '

', - ), - 'detail_list' => array( - '#theme' => 'item_list', - '#items' => $items, - ), - 'description_bottom' => array( - '#markup' => '

' . $description_bottom . '

', - ), - ); + public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { } - /** - * Determine if the handler is considered 'broken' - */ - public function broken() { return TRUE; } - } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/relationship/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/relationship/Broken.php index 19d49c70d40..16ee48cf623 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/relationship/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/relationship/Broken.php @@ -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' => '

' . $description_top . '

', - ), - 'detail_list' => array( - '#theme' => 'item_list', - '#items' => $items, - ), - 'description_bottom' => array( - '#markup' => '

' . $description_bottom . '

', - ), - ); - } - - /** - * {@inheritdoc} - */ - public function broken() { - return TRUE; - } + use BrokenHandlerTrait; } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/sort/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/sort/Broken.php index 234ee57b546..a7026255507 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/sort/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/sort/Broken.php @@ -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' => '

' . $description_top . '

', - ), - 'detail_list' => array( - '#theme' => 'item_list', - '#items' => $items, - ), - 'description_bottom' => array( - '#markup' => '

' . $description_bottom . '

', - ), - ); - } - - /** - * Determine if the handler is considered 'broken' - */ - public function broken() { return TRUE; } + use BrokenHandlerTrait; }