diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php index db0d6f8..f1b65d1 100644 --- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php +++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php @@ -132,12 +132,12 @@ protected function defineOptions() { return $options; } - protected function valueForm(&$form, FormStateInterface $formState) { + protected function valueForm(&$form, FormStateInterface $form_state) { if (empty($this->valueOptions)) { // Initialize the array of possible values for this filter. $this->getValueOptions(); } - if ($exposed = $formState->get('exposed')) { + if ($exposed = $form_state->get('exposed')) { // Exposed filter: use a select box to save space. $filter_form_type = 'select'; } @@ -153,10 +153,10 @@ protected function valueForm(&$form, FormStateInterface $formState) { ); if (!empty($this->options['exposed'])) { $identifier = $this->options['expose']['identifier']; - $user_input = $formState->getUserInput(); + $user_input = $form_state->getUserInput(); if ($exposed && !isset($user_input[$identifier])) { $user_input[$identifier] = $this->value; - $formState->setUserInput($user_input); + $form_state->setUserInput($user_input); } // If we're configuring an exposed filter, add an - Any - option. if (!$exposed || empty($this->options['expose']['required'])) { @@ -165,9 +165,9 @@ protected function valueForm(&$form, FormStateInterface $formState) { } } - protected function valueValidate($form, FormStateInterface $formState) { - if ($formState->getValue(array('options', 'value')) == 'All' && !$formState->isValueEmpty(array('options', 'expose', 'required'))) { - $formState->setErrorByName('value', $this->t('You must select a value unless this is an non-required exposed filter.')); + protected function valueValidate($form, FormStateInterface $form_state) { + if ($form_state->getValue(array('options', 'value')) == 'All' && !$form_state->isValueEmpty(array('options', 'expose', 'required'))) { + $form_state->setErrorByName('value', $this->t('You must select a value unless this is an non-required exposed filter.')); } } diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php index 8f831d0..d6da498 100644 --- a/core/modules/views/src/Plugin/views/filter/InOperator.php +++ b/core/modules/views/src/Plugin/views/filter/InOperator.php @@ -32,7 +32,12 @@ class InOperator extends FilterPluginBase { * @var array * Stores all operations which are available on the form. */ - var $valueOptions = NULL; + protected $valueOptions = NULL; + + /** + * @var string + */ + protected $valueTitle = NULL; /** * Overrides \Drupal\views\Plugin\views\filter\FilterPluginBase::init(). @@ -80,8 +85,8 @@ public function defaultExposeOptions() { $this->options['expose']['reduce'] = FALSE; } - public function buildExposeForm(&$form, FormStateInterface $formState) { - parent::buildExposeForm($form, $formState); + public function buildExposeForm(&$form, FormStateInterface $form_state) { + parent::buildExposeForm($form, $form_state); $form['expose']['reduce'] = array( '#type' => 'checkbox', '#title' => $this->t('Limit list to selected items'), @@ -166,11 +171,11 @@ protected function operatorValues($values = 1) { return $options; } - protected function valueForm(&$form, FormStateInterface $formState) { + protected function valueForm(&$form, FormStateInterface $form_state) { $form['value'] = array(); $options = array(); - $exposed = $formState->get('exposed'); + $exposed = $form_state->get('exposed'); if (!$exposed) { // Add a select all option to the value form. $options = array('all' => $this->t('Select all')); @@ -178,7 +183,7 @@ protected function valueForm(&$form, FormStateInterface $formState) { $this->getValueOptions(); $options += $this->valueOptions; - $defaultValue = (array) $this->value; + $default_value = (array) $this->value; $which = 'all'; if (!empty($form['operator'])) { @@ -199,21 +204,21 @@ protected function valueForm(&$form, FormStateInterface $formState) { $options = $this->reduceValueOptions(); if (!empty($this->options['expose']['multiple']) && empty($this->options['expose']['required'])) { - $defaultValue = array(); + $default_value = array(); } } if (empty($this->options['expose']['multiple'])) { - if (empty($this->options['expose']['required']) && (empty($defaultValue) || !empty($this->options['expose']['reduce']))) { - $defaultValue = 'All'; + if (empty($this->options['expose']['required']) && (empty($default_value) || !empty($this->options['expose']['reduce']))) { + $default_value = 'All'; } - elseif (empty($defaultValue)) { + elseif (empty($default_value)) { $keys = array_keys($options); - $defaultValue = array_shift($keys); + $default_value = array_shift ($keys); } else { - $copy = $defaultValue; - $defaultValue = array_shift($copy); + $copy = $default_value; + $default_value = array_shift($copy); } } } @@ -223,15 +228,15 @@ protected function valueForm(&$form, FormStateInterface $formState) { '#type' => $this->valueFormType, '#title' => $this->valueTitle, '#options' => $options, - '#default_value' => $defaultValue, + '#default_value' => $default_value, // These are only valid for 'select' type, but do no harm to checkboxes. '#multiple' => TRUE, '#size' => count($options) > 8 ? 8 : count($options), ); - $user_input = $formState->getUserInput(); + $user_input = $form_state->getUserInput(); if ($exposed && !isset($user_input[$identifier])) { - $user_input[$identifier] = $defaultValue; - $formState->setUserInput($user_input); + $user_input[$identifier] = $default_value; + $form_state->setUserInput($user_input); } if ($which == 'all') { @@ -299,7 +304,7 @@ public function acceptExposedInput($input) { return parent::acceptExposedInput($input); } - protected function valueSubmit($form, FormStateInterface $formState) { + protected function valueSubmit($form, FormStateInterface $form_state) { // Drupal's FAPI system automatically puts '0' in for any checkbox that // was not set, and the key to the checkbox if it is set. // Unfortunately, this means that if the key to that checkbox is 0, @@ -309,7 +314,7 @@ protected function valueSubmit($form, FormStateInterface $formState) { // *only* a list of checkboxes that were set, and we can use that // instead. - $formState->setValue(array('options', 'value'), $form['value']['#value']); + $form_state->setValue(array('options', 'value'), $form['value']['#value']); } public function adminSummary() {