class ViewsEFFieldset in Views Exposed Form Fieldset 8
Views EF Fieldset display extender plugin.
Plugin annotation
@ViewsDisplayExtender(
  id = "views_ef_fieldset",
  title = @Translation("Views EF Fieldset display extender"),
  help = @Translation("Views EF Fieldset settings for this view."),
  no_ui = FALSE
)
  Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\views\Plugin\views\PluginBase implements DependentPluginInterface, ContainerFactoryPluginInterface, TrustedCallbackInterface, ViewsPluginInterface
- class \Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase
- class \Drupal\views\Plugin\views\display_extender\DefaultDisplayExtender
- class \Drupal\views_ef_fieldset\Plugin\views\display_extender\ViewsEFFieldset
 
 
 - class \Drupal\views\Plugin\views\display_extender\DefaultDisplayExtender
 
 - class \Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase
 
 - class \Drupal\views\Plugin\views\PluginBase implements DependentPluginInterface, ContainerFactoryPluginInterface, TrustedCallbackInterface, ViewsPluginInterface
 
 - class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
 
Expanded class hierarchy of ViewsEFFieldset
File
- src/
Plugin/ views/ display_extender/ ViewsEFFieldset.php, line 26  
Namespace
Drupal\views_ef_fieldset\Plugin\views\display_extenderView source
class ViewsEFFieldset extends DefaultDisplayExtender {
  /**
   * The render object.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;
  /**
   * The constructor.
   *
   * @param array $configuration
   *   Site configuration.
   * @param string $plugin_id
   *   Plugin id.
   * @param mixed $plugin_definition
   *   Plugin definition.
   * @param \Drupal\Core\Render\RendererInterface $render
   *   The render.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, RendererInterface $render) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->renderer = $render;
  }
  /**
   * {@inheritDoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('renderer'));
  }
  /**
   * {@inheritDoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    if ($form_state
      ->get('section') !== 'exposed_form_options') {
      return [];
    }
    $options = $this->options['views_ef_fieldset'];
    $defaults = $this
      ->getPluginDefinition();
    $form['views_ef_fieldset'] = [
      '#tree' => TRUE,
    ];
    $form['views_ef_fieldset']['enabled'] = [
      '#type' => 'checkbox',
      '#default_value' => isset($options['enabled']) ? $options['enabled'] : $defaults['views_ef_fieldset']['enabled']['default'],
      '#title' => t('Enable fieldset around exposed forms ?'),
    ];
    $form['views_ef_fieldset']['options'] = [
      '#type' => 'fieldset',
      '#title' => t('Exposed form fieldset options'),
      '#states' => [
        'visible' => [
          ':input[name="views_ef_fieldset[enabled]"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ];
    $exposed_fields = $this->view
      ->getHandlers('filter');
    foreach ($exposed_fields as $exposed_field_index => $exposed_field) {
      $exposed_fields[$exposed_field_index]['handler_type'] = 'filter';
      if ((bool) $exposed_field['exposed'] !== TRUE) {
        unset($exposed_fields[$exposed_field_index]);
      }
      elseif ((bool) $exposed_field['expose']['use_operator'] === TRUE) {
        $exposed_operator = [];
        $exposed_operator['handler_type'] = 'filter';
        $exposed_operator['id'] = $exposed_field['expose']['operator_id'];
        $exposed_operator['expose'] = [
          'label' => ($exposed_field['expose']['multiple'] ? $exposed_field['expose']['placeholder_text_multiple'] : $exposed_field['expose']['placeholder_text_single']) . ' (' . $exposed_field['expose']['label'] . ')',
        ];
        $exposed_fields[] = $exposed_operator;
      }
    }
    $sort_fields = $this->view
      ->getHandlers('sort');
    foreach ($sort_fields as $sort_fields_index => $sort_field) {
      $sort_fields[$sort_fields_index]['handler_type'] = 'sort';
      if ((bool) $sort_field['exposed'] !== TRUE) {
        unset($sort_fields[$sort_fields_index]);
      }
    }
    if (!empty($sort_fields)) {
      $sort_by = [];
      $sort_by['handler_type'] = 'sort';
      $sort_by['id'] = 'sort_by';
      $sort_by['expose'] = [
        'label' => 'Sort by',
      ];
      $exposed_fields[] = $sort_by;
    }
    if ($form['exposed_form_options']['expose_sort_order']['#default_value'] === 1 && count($sort_fields)) {
      $sort_order = [];
      $sort_order['handler_type'] = 'sort';
      $sort_order['id'] = 'sort_order';
      $sort_order['expose'] = [
        'label' => 'Sort order',
      ];
      $exposed_fields[] = $sort_order;
    }
    $submit_button = [];
    $submit_button['handler_type'] = 'buttons';
    $submit_button['id'] = 'submit';
    $submit_button['expose'] = [
      'label' => 'Submit button',
    ];
    $exposed_fields[] = $submit_button;
    if ($form['exposed_form_options']['reset_button']['#default_value'] === 1) {
      $reset_button = [];
      $reset_button['handler_type'] = 'buttons';
      $reset_button['id'] = 'reset';
      $reset_button['expose'] = [
        'label' => 'Reset button',
      ];
      $exposed_fields[] = $reset_button;
    }
    foreach (array_values($exposed_fields) as $exposed_field_index => $exposed_field) {
      $container = [];
      $container['handler_type'] = 'container';
      $container['type'] = 'container';
      $container['container_type'] = 'details';
      $container['weight'] = $exposed_field_index;
      $container['expose'] = [
        'label' => 'Container ' . $exposed_field_index,
      ];
      $container['id'] = 'container-' . $exposed_field_index;
      $exposed_fields[] = $container;
    }
    $data = [
      [
        'id' => 'root',
        'type' => 'container',
        'weight' => 0,
        'pid' => '',
        'label' => 'Root',
        'title' => isset($options['options']['sort']['root']['title']) ? $options['options']['sort']['root']['title'] : t('Filters'),
        'description' => $options['options']['sort']['root']['description'],
        'open' => isset($options['options']['sort']['root']['open']) ? (bool) $options['options']['sort']['root']['open'] : TRUE,
        'container_type' => isset($options['options']['sort']['root']['container_type']) ? $options['options']['sort']['root']['container_type'] : 'details',
      ],
    ];
    foreach ($exposed_fields as $index => $field) {
      $field_options = $options['options']['sort'][$field['id']];
      $label = $field['expose']['label'] ? $field['expose']['label'] : $field['id'];
      $data[] = [
        'id' => $field['id'],
        'weight' => isset($field_options['weight']) ? $field_options['weight'] : (isset($field->weight) ? $field->weight : $index - count($exposed_fields)),
        'pid' => empty($field_options['pid']) ? 'root' : $field_options['pid'],
        'label' => $label,
        'title' => isset($field_options['title']) ? $field_options['title'] : $label,
        'description' => isset($field_options['description']) ? $field_options['description'] : '',
        'open' => isset($field_options['open']) ? (bool) $field_options['open'] : FALSE,
        'type' => $field['handler_type'],
        'container_type' => isset($field_options['container_type']) ? $field_options['container_type'] : 'details',
      ];
    }
    $viewsEFFieldsetData = new ViewsEFFieldsetData($data);
    $table = [
      '#type' => 'table',
      '#header' => [
        t('Label'),
        t('Type'),
        t('Title'),
        t('Description'),
        t('Open'),
        t('Weight'),
      ],
      '#tabledrag' => [
        [
          'action' => 'match',
          'relationship' => 'parent',
          'group' => 'item-pid',
          'subgroup' => 'item-pid',
          'source' => 'item-id',
          'hidden' => FALSE,
        ],
        [
          'action' => 'depth',
          'relationship' => 'group',
          'group' => 'item-depth',
          'hidden' => FALSE,
        ],
        [
          'action' => 'order',
          'relationship' => 'sibling',
          'group' => 'item-weight',
        ],
      ],
    ];
    foreach ($viewsEFFieldsetData
      ->buildFlat() as $item) {
      $item = $item['item'];
      $indentation = [];
      if (isset($item['depth']) && $item['depth'] > 0) {
        $indentation = [
          '#theme' => 'indentation',
          '#size' => $item['depth'],
        ];
      }
      $title = $item['title'];
      if ($item['type'] === 'container') {
        if ($item['id'] === 'root') {
          $title = '<em>' . $title . '</em>';
        }
        $title = '<strong>' . $title . '</strong>';
      }
      $table[$item['id']] = [
        '#item' => $item,
        'item' => [
          '#prefix' => !empty($indentation) ? $this->renderer
            ->render($indentation) : '',
          '#markup' => $title,
          '#wrapper_attributes' => [
            'colspan' => $item['type'] === 'container' ? '' : [
              'colspan' => 5,
            ],
          ],
          'id' => [
            '#type' => 'hidden',
            '#default_value' => $item['id'],
            '#size' => 4,
            '#attributes' => [
              'class' => [
                'item-id',
              ],
            ],
          ],
          'pid' => [
            '#type' => 'hidden',
            '#default_value' => $item['pid'],
            '#size' => 4,
            '#attributes' => [
              'class' => [
                'item-pid',
              ],
            ],
          ],
          'depth' => [
            '#type' => 'hidden',
            '#default_value' => $item['depth'],
            '#attributes' => [
              'class' => [
                'item-depth',
              ],
            ],
          ],
          'type' => [
            '#type' => 'hidden',
            '#default_value' => $item['type'],
          ],
        ],
      ];
      if ($item['type'] === 'container') {
        $table[$item['id']] += [
          'container_type' => [
            '#type' => 'select',
            '#default_value' => $item['container_type'],
            '#options' => [
              'container' => 'Container',
              'details' => 'Fieldset',
              'vertical_tabs' => 'Vertical tabs',
            ],
          ],
          'title' => [
            '#type' => 'textfield',
            '#size' => 15,
            '#default_value' => $item['title'],
          ],
          'description' => [
            '#type' => 'textfield',
            '#size' => 15,
            '#default_value' => $item['description'],
          ],
          'open' => [
            '#type' => 'checkbox',
            '#default_value' => $item['open'],
          ],
        ];
      }
      $table[$item['id']] += [
        'weight' => [
          '#item' => $item,
          '#type' => 'weight',
          '#title' => $item['title'],
          '#delta' => count($data),
          '#title_display' => 'invisible',
          '#default_value' => $item['weight'],
          '#attributes' => [
            'class' => [
              'item-weight',
            ],
          ],
        ],
      ];
      if ($item['id'] !== 'root') {
        $table[$item['id']]['#attributes']['class'][] = 'draggable';
      }
    }
    $form['views_ef_fieldset']['options']['sort'] = $table;
  }
  /**
   * {@inheritdoc}
   */
  public function getPluginDefinition() {
    $options = parent::defineOptions();
    $options['views_ef_fieldset'] = [
      'enabled' => [
        'default' => FALSE,
        'bool' => TRUE,
      ],
      'options' => [],
    ];
    return $options;
  }
  /**
   * {@inheritdoc}
   */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    // Only process options if this is an unrelated form.
    if ($form_state
      ->get('section') === 'exposed_form_options') {
      $views_ef_fieldset = $form_state
        ->getValue('views_ef_fieldset');
      foreach ($views_ef_fieldset['options']['sort'] as $key => $data) {
        $data += $data['item'];
        unset($data['item']);
        $views_ef_fieldset['options']['sort'][$key] = $data;
      }
      $this->options['views_ef_fieldset'] = $views_ef_fieldset;
    }
    parent::submitOptionsForm($form, $form_state);
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            DependencySerializationTrait:: | 
                  protected | property | An array of entity type IDs keyed by the property name of their storages. | |
| 
            DependencySerializationTrait:: | 
                  protected | property | An array of service IDs keyed by property name used for serialization. | |
| 
            DependencySerializationTrait:: | 
                  public | function | 1 | |
| 
            DependencySerializationTrait:: | 
                  public | function | 2 | |
| 
            DisplayExtenderPluginBase:: | 
                  public | function | Static member function to list which sections are defaultable and what items each section contains. | 1 | 
| 
            DisplayExtenderPluginBase:: | 
                  public | function | Provide a form to edit options for this plugin. | |
| 
            DisplayExtenderPluginBase:: | 
                  public | function | Provide the default summary for options in the views UI. | 1 | 
| 
            DisplayExtenderPluginBase:: | 
                  public | function | Set up any variables on the view prior to execution. | 1 | 
| 
            DisplayExtenderPluginBase:: | 
                  public | function | 
            Inject anything into the query that the display_extender handler needs. Overrides PluginBase:: | 
                  1 | 
| 
            DisplayExtenderPluginBase:: | 
                  public | function | 
            Validate the options form. Overrides PluginBase:: | 
                  |
| 
            MessengerTrait:: | 
                  protected | property | The messenger. | 29 | 
| 
            MessengerTrait:: | 
                  public | function | Gets the messenger. | 29 | 
| 
            MessengerTrait:: | 
                  public | function | Sets the messenger. | |
| 
            PluginBase:: | 
                  protected | property | Configuration information passed into the plugin. | 1 | 
| 
            PluginBase:: | 
                  public | property | Plugins's definition | |
| 
            PluginBase:: | 
                  public | property | The display object this plugin is for. | |
| 
            PluginBase:: | 
                  public | property | Options for this plugin will be held here. | |
| 
            PluginBase:: | 
                  protected | property | The plugin implementation definition. | 1 | 
| 
            PluginBase:: | 
                  protected | property | The plugin_id. | |
| 
            PluginBase:: | 
                  protected | property | Denotes whether the plugin has an additional options form. | 8 | 
| 
            PluginBase:: | 
                  public | property | The top object of a view. | 1 | 
| 
            PluginBase:: | 
                  public | function | 
            Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: | 
                  14 | 
| 
            PluginBase:: | 
                  protected | function | Information about options for all kinds of purposes will be held here. | 18 | 
| 
            PluginBase:: | 
                  constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
| 
            PluginBase:: | 
                  public | function | 
            Clears a plugin. Overrides ViewsPluginInterface:: | 
                  2 | 
| 
            PluginBase:: | 
                  protected | function | Do the work to filter out stored options depending on the defined options. | |
| 
            PluginBase:: | 
                  public | function | 
            Filter out stored options depending on the defined options. Overrides ViewsPluginInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | 
            Returns an array of available token replacements. Overrides ViewsPluginInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | 
            Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | 
            Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | 
            Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | 
            Returns the plugin provider. Overrides ViewsPluginInterface:: | 
                  |
| 
            PluginBase:: | 
                  protected | function | Returns the render API renderer. | 1 | 
| 
            PluginBase:: | 
                  public | function | 
            Adds elements for available core tokens to a form. Overrides ViewsPluginInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | 
            Returns a string with any core tokens replaced. Overrides ViewsPluginInterface:: | 
                  |
| 
            PluginBase:: | 
                  constant | Include entity row languages when listing languages. | ||
| 
            PluginBase:: | 
                  constant | Include negotiated languages when listing languages. | ||
| 
            PluginBase:: | 
                  public | function | 
            Initialize the plugin. Overrides ViewsPluginInterface:: | 
                  8 | 
| 
            PluginBase:: | 
                  public | function | Determines if the plugin is configurable. | |
| 
            PluginBase:: | 
                  protected | function | Makes an array of languages, optionally including special languages. | |
| 
            PluginBase:: | 
                  public | function | 
            Return the human readable name of the display. Overrides ViewsPluginInterface:: | 
                  |
| 
            PluginBase:: | 
                  public static | function | 
            Moves form elements into fieldsets for presentation purposes. Overrides ViewsPluginInterface:: | 
                  |
| 
            PluginBase:: | 
                  public static | function | 
            Flattens the structure of form elements. Overrides ViewsPluginInterface:: | 
                  |
| 
            PluginBase:: | 
                  public static | function | Returns substitutions for Views queries for languages. | |
| 
            PluginBase:: | 
                  protected | function | Fills up the options of the plugin with defaults. | |
| 
            PluginBase:: | 
                  public | function | 
            Returns the summary of the settings in the display. Overrides ViewsPluginInterface:: | 
                  6 | 
| 
            PluginBase:: | 
                  public | function | 
            Provide a full list of possible theme templates used by this style. Overrides ViewsPluginInterface:: | 
                  1 | 
| 
            PluginBase:: | 
                  public static | function | 
            Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: | 
                  6 | 
| 
            PluginBase:: | 
                  public | function | 
            Unpack options over our existing defaults, drilling down into arrays
so that defaults don't get totally blown away. Overrides ViewsPluginInterface:: | 
                  |
| 
            PluginBase:: | 
                  public | function | 
            Returns the usesOptions property. Overrides ViewsPluginInterface:: | 
                  8 | 
| 
            PluginBase:: | 
                  public | function | 
            Validate that the plugin is correct and can be saved. Overrides ViewsPluginInterface:: | 
                  6 | 
| 
            PluginBase:: | 
                  protected | function | Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin. | 1 | 
| 
            PluginBase:: | 
                  constant | Query string to indicate the site default language. | ||
| 
            StringTranslationTrait:: | 
                  protected | property | The string translation service. | 1 | 
| 
            StringTranslationTrait:: | 
                  protected | function | Formats a string containing a count of items. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Returns the number of plurals supported by a given language. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Gets the string translation service. | |
| 
            StringTranslationTrait:: | 
                  public | function | Sets the string translation service to use. | 2 | 
| 
            StringTranslationTrait:: | 
                  protected | function | Translates a string to the current language or to a given language. | |
| 
            TrustedCallbackInterface:: | 
                  constant | Untrusted callbacks throw exceptions. | ||
| 
            TrustedCallbackInterface:: | 
                  constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
| 
            TrustedCallbackInterface:: | 
                  constant | Untrusted callbacks trigger E_USER_WARNING errors. | ||
| 
            ViewsEFFieldset:: | 
                  protected | property | 
            The render object. Overrides PluginBase:: | 
                  |
| 
            ViewsEFFieldset:: | 
                  public | function | 
            Provide a form to edit options for this plugin. Overrides DisplayExtenderPluginBase:: | 
                  |
| 
            ViewsEFFieldset:: | 
                  public static | function | 
            Creates an instance of the plugin. Overrides PluginBase:: | 
                  |
| 
            ViewsEFFieldset:: | 
                  public | function | 
            Gets the definition of the plugin implementation. Overrides PluginBase:: | 
                  |
| 
            ViewsEFFieldset:: | 
                  public | function | 
            Handle any special handling on the validate form. Overrides DisplayExtenderPluginBase:: | 
                  |
| 
            ViewsEFFieldset:: | 
                  public | function | 
            The constructor. Overrides PluginBase:: |