mirrored from http://git.drupal.org/project/drupal.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #2206809 by damiankloip: Convert broken handlers to use a trait.
- Loading branch information
Nathaniel Catchpole
committed
Mar 7, 2014
1 parent
a66e958
commit 9065f49
Showing
7 changed files
with
121 additions
and
356 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
core/modules/views/lib/Drupal/views/Plugin/views/BrokenHandlerTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.