3 namespace Drupal\views\Plugin\views;
5 use Drupal\Component\Render\FormattableMarkup;
6 use Drupal\Core\Form\FormStateInterface;
9 * A Trait for Views broken handlers.
11 trait BrokenHandlerTrait {
14 * Returns this handlers name in the UI.
16 * @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
18 public function adminLabel($short = FALSE) {
19 return t('Broken/missing handler');
23 * The option definition for this handler.
25 * @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
27 public function defineOptions() {
32 * Ensure the main table for this handler is in the query. This is used
35 * @see \Drupal\views\Plugin\views\HandlerBase::ensureMyTable()
37 public function ensureMyTable() {
38 // No table to ensure.
42 * Modify the views query.
44 public function query($group_by = FALSE) {
49 * Provides a form to edit options for this plugin.
51 * @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
53 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
54 $description_top = t('The handler for this item is broken or missing. The following details are available:');
56 foreach ($this->definition['original_configuration'] as $key => $value) {
57 if (is_scalar($value)) {
58 $items[] = new FormattableMarkup('@key: @value', ['@key' => $key, '@value' => $value]);
62 $description_bottom = t('Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.');
64 $form['description'] = [
65 '#type' => 'container',
67 'class' => ['js-form-item', 'form-item', 'description'],
69 'description_top' => [
70 '#markup' => '<p>' . $description_top . '</p>',
73 '#theme' => 'item_list',
76 'description_bottom' => [
77 '#markup' => '<p>' . $description_bottom . '</p>',
83 * Determines if the handler is considered 'broken'.
85 * This means it's a placeholder used when a handler can't be found.
87 * @see \Drupal\views\Plugin\views\HandlerBase::broken()
89 public function broken() {
94 * Gets dependencies for a broken handler.
98 * @see \Drupal\views\Plugin\views\PluginBase::calculateDependencies()
100 public function calculateDependencies() {