function TranslateFormBase::translateFilterValues
Same name in other branches
- 9 core/modules/locale/src/Form/TranslateFormBase.php \Drupal\locale\Form\TranslateFormBase::translateFilterValues()
- 8.9.x core/modules/locale/src/Form/TranslateFormBase.php \Drupal\locale\Form\TranslateFormBase::translateFilterValues()
- 10 core/modules/locale/src/Form/TranslateFormBase.php \Drupal\locale\Form\TranslateFormBase::translateFilterValues()
Builds an array out of search criteria specified in request variables.
Parameters
bool $reset: If the list of values should be reset.
Return value
array The filter values.
3 calls to TranslateFormBase::translateFilterValues()
- TranslateEditForm::buildForm in core/
modules/ locale/ src/ Form/ TranslateEditForm.php - Form constructor.
- TranslateFilterForm::buildForm in core/
modules/ locale/ src/ Form/ TranslateFilterForm.php - Form constructor.
- TranslateFormBase::translateFilterLoadStrings in core/
modules/ locale/ src/ Form/ TranslateFormBase.php - Builds a string search query and returns an array of string objects.
File
-
core/
modules/ locale/ src/ Form/ TranslateFormBase.php, line 121
Class
- TranslateFormBase
- Defines the locale user interface translation form base.
Namespace
Drupal\locale\FormCode
protected function translateFilterValues($reset = FALSE) {
if (!$reset && static::$filterValues) {
return static::$filterValues;
}
$filter_values = [];
$filters = $this->translateFilters();
$request = $this->getRequest();
$session_filters = $request->getSession()
->get('locale_translate_filter', []);
foreach ($filters as $key => $filter) {
$filter_values[$key] = $filter['default'];
// Let the filter defaults be overwritten by parameters in the URL.
if ($request->query
->has($key)) {
// Only allow this value if it was among the options, or
// if there were no fixed options to filter for.
$value = $request->query
->get($key);
if (!isset($filter['options']) || isset($filter['options'][$value])) {
$filter_values[$key] = $value;
}
}
elseif (isset($session_filters[$key])) {
// Only allow this value if it was among the options, or
// if there were no fixed options to filter for.
if (!isset($filter['options']) || isset($filter['options'][$session_filters[$key]])) {
$filter_values[$key] = $session_filters[$key];
}
}
}
return static::$filterValues = $filter_values;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.