protected function WizardPluginBase::default_display_filters_user

Retrieves filter information based on user input for the default display.

Parameters

array $form: The full wizard form array.

array $form_state: The current state of the wizard form.

Return value

array An array of filter arrays keyed by ID. A sort array contains the options accepted by a filter handler.

2 calls to WizardPluginBase::default_display_filters_user()
Node::default_display_filters_user in drupal/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php
Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::default_display_filters_user().
WizardPluginBase::default_display_filters in drupal/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php
Retrieves all filter information used by the default display.
1 method overrides WizardPluginBase::default_display_filters_user()
Node::default_display_filters_user in drupal/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php
Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::default_display_filters_user().

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php, line 818
Definition of Drupal\views\Plugin\views\wizard\WizardPluginBase.

Class

WizardPluginBase
Provides the interface and base class for Views Wizard plugins.

Namespace

Drupal\views\Plugin\views\wizard

Code

protected function default_display_filters_user(array $form, array &$form_state) {
  $filters = array();
  if (!empty($form_state['values']['show']['type']) && $form_state['values']['show']['type'] != 'all') {
    $bundle_key = $this->entity_info['bundle_keys']['bundle'];

    // Figure out the table where $bundle_key lives. It may not be the same as
    // the base table for the view; the taxonomy vocabulary machine_name, for
    // example, is stored in taxonomy_vocabulary, not taxonomy_term_data.
    $fields = views_fetch_fields($this->base_table, 'filter');
    if (isset($fields[$this->base_table . '.' . $bundle_key])) {
      $table = $this->base_table;
    }
    else {
      foreach ($fields as $field_name => $value) {
        if ($pos = strpos($field_name, '.' . $bundle_key)) {
          $table = substr($field_name, 0, $pos);
          break;
        }
      }
    }
    $table_data = views_fetch_data($table);

    // If the 'in' operator is being used, map the values to an array.
    $handler = $table_data[$bundle_key]['filter']['id'];
    $handler_definition = drupal_container()
      ->get('plugin.manager.views.filter')
      ->getDefinition($handler);
    if ($handler == 'in_operator' || is_subclass_of($handler_definition['class'], 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) {
      $value = drupal_map_assoc(array(
        $form_state['values']['show']['type'],
      ));
    }
    else {
      $value = $form_state['values']['show']['type'];
    }
    $filters[$bundle_key] = array(
      'id' => $bundle_key,
      'table' => $table,
      'field' => $bundle_key,
      'value' => $value,
    );
  }
  return $filters;
}