protected function WizardPluginBase::defaultDisplaySortsUser in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php \Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplaySortsUser()
Retrieves sort information based on user input for the default display.
Parameters
array $form: The full wizard form array.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the wizard form.
Return value
array An array of sort arrays keyed by ID. A sort array contains the options accepted by a sort handler.
1 call to WizardPluginBase::defaultDisplaySortsUser()
- WizardPluginBase::defaultDisplaySorts in core/
modules/ views/ src/ Plugin/ views/ wizard/ WizardPluginBase.php - Retrieves all sort information used by the default display.
File
- core/
modules/ views/ src/ Plugin/ views/ wizard/ WizardPluginBase.php, line 976 - Contains \Drupal\views\Plugin\views\wizard\WizardPluginBase.
Class
- WizardPluginBase
- Base class for Views wizard plugins.
Namespace
Drupal\views\Plugin\views\wizardCode
protected function defaultDisplaySortsUser($form, FormStateInterface $form_state) {
$sorts = array();
// Don't add a sort if there is no form value or the user set the sort to
// 'none'.
if (($sort_type = $form_state
->getValue(array(
'show',
'sort',
))) && $sort_type != 'none') {
list($column, $sort) = explode(':', $sort_type);
// Column either be a column-name or the table-column-name.
$column = explode('-', $column);
if (count($column) > 1) {
$table = $column[0];
$column = $column[1];
}
else {
$table = $this->base_table;
$column = $column[0];
}
// If the input is invalid, for example when the #default_value contains
// created from node, but the wizard type is another base table, make
// sure it is not added. This usually don't happen if you have js
// enabled.
$data = Views::viewsData()
->get($table);
if (isset($data[$column]['sort'])) {
$sorts[$column] = array(
'id' => $column,
'table' => $table,
'field' => $column,
'order' => $sort,
'entity_type' => isset($data['table']['entity type']) ? $data['table']['entity type'] : NULL,
'entity_field' => isset($data[$column]['entity field']) ? $data[$column]['entity field'] : NULL,
'plugin_id' => $data[$column]['sort']['id'],
);
}
}
return $sorts;
}