Retrieves filter information based on user input for the default display.
array $form: The full wizard form array.
array $form_state: The current state of the wizard form.
array An array of filter arrays keyed by ID. A sort array contains the options accepted by a filter handler.
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;
}