trait BrokenHandlerTrait

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/BrokenHandlerTrait.php \Drupal\views\Plugin\views\BrokenHandlerTrait
  2. 8.9.x core/modules/views/src/Plugin/views/BrokenHandlerTrait.php \Drupal\views\Plugin\views\BrokenHandlerTrait
  3. 11.x core/modules/views/src/Plugin/views/BrokenHandlerTrait.php \Drupal\views\Plugin\views\BrokenHandlerTrait

A Trait for Views broken handlers.

Hierarchy

6 files declare their use of BrokenHandlerTrait
Broken.php in core/modules/views/src/Plugin/views/sort/Broken.php
Broken.php in core/modules/views/src/Plugin/views/field/Broken.php
Broken.php in core/modules/views/src/Plugin/views/relationship/Broken.php
Broken.php in core/modules/views/src/Plugin/views/filter/Broken.php
Broken.php in core/modules/views/src/Plugin/views/area/Broken.php

... See full list

File

core/modules/views/src/Plugin/views/BrokenHandlerTrait.php, line 11

Namespace

Drupal\views\Plugin\views
View source
trait BrokenHandlerTrait {
    
    /**
     * Returns this handlers name in the UI.
     *
     * @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
     */
    public function adminLabel($short = FALSE) {
        return $this->t('Broken/missing handler');
    }
    
    /**
     * The option definition for this handler.
     *
     * @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
     */
    public function defineOptions() {
        return [];
    }
    
    /**
     * Ensures that the main table for this handler is in the query.
     *
     * @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, FormStateInterface $form_state) {
        $description_top = $this->t('The handler for this item is broken or missing. The following details are available:');
        foreach ($this->definition['original_configuration'] as $key => $value) {
            if (is_scalar($value)) {
                $items[] = new FormattableMarkup('@key: @value', [
                    '@key' => $key,
                    '@value' => $value,
                ]);
            }
        }
        $description_bottom = $this->t('Installing the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.');
        $form['description'] = [
            '#type' => 'container',
            '#attributes' => [
                'class' => [
                    'js-form-item',
                    'form-item',
                    'description',
                ],
            ],
            'description_top' => [
                '#markup' => '<p>' . $description_top . '</p>',
            ],
            'detail_list' => [
                '#theme' => 'item_list',
                '#items' => $items,
            ],
            'description_bottom' => [
                '#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;
    }
    
    /**
     * Gets dependencies for a broken handler.
     *
     * @return array
     *
     * @see \Drupal\views\Plugin\views\PluginBase::calculateDependencies()
     */
    public function calculateDependencies() {
        return [];
    }

}

Members

Title Sort descending Modifiers Object type Summary
BrokenHandlerTrait::adminLabel public function Returns this handlers name in the UI.
BrokenHandlerTrait::broken public function Determines if the handler is considered &#039;broken&#039;.
BrokenHandlerTrait::buildOptionsForm public function Provides a form to edit options for this plugin.
BrokenHandlerTrait::calculateDependencies public function Gets dependencies for a broken handler.
BrokenHandlerTrait::defineOptions public function The option definition for this handler.
BrokenHandlerTrait::ensureMyTable public function Ensures that the main table for this handler is in the query.
BrokenHandlerTrait::query public function Modify the views query.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.