From 3bb1ac58851c91c64c16e2bee67802a2597471f8 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Thu, 2 Oct 2014 14:22:38 +0200
Subject: [PATCH] Issue #2183421 by alimac, Crisz, InternetDevels, schnippy,
 evilehk, bender404 | bohart: In InOperator Rename Views properties to core
 standards.

---
 .../src/Plugin/views/filter/NodeComment.php   |  2 +-
 .../src/Plugin/views/filter/FieldList.php     |  2 +-
 .../file/src/Plugin/views/filter/Status.php   |  4 +-
 .../Plugin/views/filter/TaxonomyIndexTid.php  |  6 +--
 .../user/src/Plugin/views/filter/Name.php     |  8 ++--
 .../src/Plugin/views/filter/Permissions.php   |  6 +--
 .../user/src/Plugin/views/filter/Roles.php    |  4 +-
 .../Plugin/views/filter/BooleanOperator.php   | 22 ++++-----
 .../views/src/Plugin/views/filter/Bundle.php  |  8 ++--
 .../src/Plugin/views/filter/InOperator.php    | 45 +++++++++++--------
 .../Plugin/views/filter/LanguageFilter.php    |  6 +--
 .../Tests/Entity/FilterEntityBundleTest.php   |  2 +-
 12 files changed, 61 insertions(+), 54 deletions(-)

diff --git a/core/modules/comment/src/Plugin/views/filter/NodeComment.php b/core/modules/comment/src/Plugin/views/filter/NodeComment.php
index cdb2496d95e3..958d6dfde074 100644
--- a/core/modules/comment/src/Plugin/views/filter/NodeComment.php
+++ b/core/modules/comment/src/Plugin/views/filter/NodeComment.php
@@ -20,7 +20,7 @@
 class NodeComment extends InOperator {
 
   public function getValueOptions() {
-    $this->value_options = array(
+    $this->valueOptions = array(
       CommentItemInterface::HIDDEN => $this->t('Hidden'),
       CommentItemInterface::CLOSED => $this->t('Closed'),
       CommentItemInterface::OPEN => $this->t('Open'),
diff --git a/core/modules/field/src/Plugin/views/filter/FieldList.php b/core/modules/field/src/Plugin/views/filter/FieldList.php
index 42061e11a2c4..f365fc4b6d0c 100644
--- a/core/modules/field/src/Plugin/views/filter/FieldList.php
+++ b/core/modules/field/src/Plugin/views/filter/FieldList.php
@@ -21,7 +21,7 @@ class FieldList extends ManyToOne {
   public function getValueOptions() {
     $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($this->definition['entity_type']);
     $field_storage = $field_storage_definitions[$this->definition['field_name']];
-    $this->value_options = list_allowed_values($field_storage);
+    $this->valueOptions = list_allowed_values($field_storage);
   }
 
 }
diff --git a/core/modules/file/src/Plugin/views/filter/Status.php b/core/modules/file/src/Plugin/views/filter/Status.php
index 963e8a062004..d28cf94086d3 100644
--- a/core/modules/file/src/Plugin/views/filter/Status.php
+++ b/core/modules/file/src/Plugin/views/filter/Status.php
@@ -19,8 +19,8 @@
 class Status extends InOperator {
 
   public function getValueOptions() {
-    if (!isset($this->value_options)) {
-      $this->value_options = _views_file_status();
+    if (!isset($this->valueOptions)) {
+      $this->valueOptions = _views_file_status();
     }
   }
 
diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
index af4811e0c787..d1b727839283 100644
--- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -348,14 +348,14 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) {
   }
 
   public function adminSummary() {
-    // set up $this->value_options for the parent summary
-    $this->value_options = array();
+    // set up $this->valueOptions for the parent summary
+    $this->valueOptions = array();
 
     if ($this->value) {
       $this->value = array_filter($this->value);
       $terms = Term::loadMultiple($this->value);
       foreach ($terms as $term) {
-        $this->value_options[$term->id()] = String::checkPlain(\Drupal::entityManager()->getTranslationFromContext($term)->label());
+        $this->valueOptions[$term->id()] = String::checkPlain(\Drupal::entityManager()->getTranslationFromContext($term)->label());
       }
     }
     return parent::adminSummary();
diff --git a/core/modules/user/src/Plugin/views/filter/Name.php b/core/modules/user/src/Plugin/views/filter/Name.php
index 10a55e25ee05..531dc5d3ad76 100644
--- a/core/modules/user/src/Plugin/views/filter/Name.php
+++ b/core/modules/user/src/Plugin/views/filter/Name.php
@@ -149,17 +149,17 @@ protected function valueSubmit($form, FormStateInterface $form_state) {
   public function getValueOptions() { }
 
   public function adminSummary() {
-    // set up $this->value_options for the parent summary
-    $this->value_options = array();
+    // set up $this->valueOptions for the parent summary
+    $this->valueOptions = array();
 
     if ($this->value) {
       $result = entity_load_multiple_by_properties('user', array('uid' => $this->value));
       foreach ($result as $account) {
         if ($account->id()) {
-          $this->value_options[$account->id()] = $account->label();
+          $this->valueOptions[$account->id()] = $account->label();
         }
         else {
-          $this->value_options[$account->id()] = 'Anonymous'; // Intentionally NOT translated.
+          $this->valueOptions[$account->id()] = 'Anonymous'; // Intentionally NOT translated.
         }
       }
     }
diff --git a/core/modules/user/src/Plugin/views/filter/Permissions.php b/core/modules/user/src/Plugin/views/filter/Permissions.php
index d3e7b50a899e..a3b26aa8230d 100644
--- a/core/modules/user/src/Plugin/views/filter/Permissions.php
+++ b/core/modules/user/src/Plugin/views/filter/Permissions.php
@@ -60,18 +60,18 @@ public static function create(ContainerInterface $container, array $configuratio
   }
 
   public function getValueOptions() {
-    if (!isset($this->value_options)) {
+    if (!isset($this->valueOptions)) {
       $module_info = system_get_info('module');
 
       $permissions = $this->permissionHandler->getPermissions();
       foreach ($permissions as $perm => $perm_item) {
         $provider = $perm_item['provider'];
         $display_name = $module_info[$provider]['name'];
-        $this->value_options[$display_name][$perm] = String::checkPlain(strip_tags($perm_item['title']));
+        $this->valueOptions[$display_name][$perm] = String::checkPlain(strip_tags($perm_item['title']));
       }
     }
     else {
-      return $this->value_options;
+      return $this->valueOptions;
     }
   }
 
diff --git a/core/modules/user/src/Plugin/views/filter/Roles.php b/core/modules/user/src/Plugin/views/filter/Roles.php
index b68b94da174f..014425df520a 100644
--- a/core/modules/user/src/Plugin/views/filter/Roles.php
+++ b/core/modules/user/src/Plugin/views/filter/Roles.php
@@ -19,8 +19,8 @@
 class Roles extends ManyToOne {
 
   public function getValueOptions() {
-    $this->value_options = user_role_names(TRUE);
-    unset($this->value_options[DRUPAL_AUTHENTICATED_RID]);
+    $this->valueOptions = user_role_names(TRUE);
+    unset($this->valueOptions[DRUPAL_AUTHENTICATED_RID]);
   }
 
   /**
diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
index 4e30ca968202..f1b65d116328 100644
--- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
@@ -90,7 +90,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
     elseif (isset($this->definition['accept_null'])) {
       $this->accept_null = (bool) $this->definition['accept_null'];
     }
-    $this->value_options = NULL;
+    $this->valueOptions = NULL;
   }
 
   /**
@@ -108,19 +108,19 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
   public function getValueOptions() {
     if (isset($this->definition['type'])) {
       if ($this->definition['type'] == 'yes-no') {
-        $this->value_options = array(1 => $this->t('Yes'), 0 => $this->t('No'));
+        $this->valueOptions = array(1 => $this->t('Yes'), 0 => $this->t('No'));
       }
       if ($this->definition['type'] == 'on-off') {
-        $this->value_options = array(1 => $this->t('On'), 0 => $this->t('Off'));
+        $this->valueOptions = array(1 => $this->t('On'), 0 => $this->t('Off'));
       }
       if ($this->definition['type'] == 'enabled-disabled') {
-        $this->value_options = array(1 => $this->t('Enabled'), 0 => $this->t('Disabled'));
+        $this->valueOptions = array(1 => $this->t('Enabled'), 0 => $this->t('Disabled'));
       }
     }
 
     // Provide a fallback if the above didn't set anything.
-    if (!isset($this->value_options)) {
-      $this->value_options = array(1 => $this->t('True'), 0 => $this->t('False'));
+    if (!isset($this->valueOptions)) {
+      $this->valueOptions = array(1 => $this->t('True'), 0 => $this->t('False'));
     }
   }
 
@@ -133,7 +133,7 @@ protected function defineOptions() {
   }
 
   protected function valueForm(&$form, FormStateInterface $form_state) {
-    if (empty($this->value_options)) {
+    if (empty($this->valueOptions)) {
       // Initialize the array of possible values for this filter.
       $this->getValueOptions();
     }
@@ -148,7 +148,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
     $form['value'] = array(
       '#type' => $filter_form_type,
       '#title' => $this->value_value,
-      '#options' => $this->value_options,
+      '#options' => $this->valueOptions,
       '#default_value' => $this->value,
     );
     if (!empty($this->options['exposed'])) {
@@ -178,14 +178,14 @@ public function adminSummary() {
     if (!empty($this->options['exposed'])) {
       return $this->t('exposed');
     }
-    if (empty($this->value_options)) {
+    if (empty($this->valueOptions)) {
       $this->getValueOptions();
     }
     // Now that we have the valid options for this filter, just return the
-    // human-readable label based on the current value.  The value_options
+    // human-readable label based on the current value.  The valueOptions
     // array is keyed with either 0 or 1, so if the current value is not
     // empty, use the label for 1, and if it's empty, use the label for 0.
-    return $this->value_options[!empty($this->value)];
+    return $this->valueOptions[!empty($this->value)];
   }
 
   public function defaultExposeOptions() {
diff --git a/core/modules/views/src/Plugin/views/filter/Bundle.php b/core/modules/views/src/Plugin/views/filter/Bundle.php
index 92b4980ef465..614a75c9f329 100644
--- a/core/modules/views/src/Plugin/views/filter/Bundle.php
+++ b/core/modules/views/src/Plugin/views/filter/Bundle.php
@@ -48,9 +48,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
    * Overrides \Drupal\views\Plugin\views\filter\InOperator::getValueOptions().
    */
   public function getValueOptions() {
-    if (!isset($this->value_options)) {
+    if (!isset($this->valueOptions)) {
       $types = entity_get_bundles($this->entityTypeId);
-      $this->value_title = $this->t('@entity types', array('@entity' => $this->entityType->getLabel()));
+      $this->valueTitle = $this->t('@entity types', array('@entity' => $this->entityType->getLabel()));
 
       $options = array();
       foreach ($types as $type => $info) {
@@ -58,10 +58,10 @@ public function getValueOptions() {
       }
 
       asort($options);
-      $this->value_options = $options;
+      $this->valueOptions = $options;
     }
 
-    return $this->value_options;
+    return $this->valueOptions;
   }
 
   /**
diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php
index cbb781eb413c..d759f71c8c7e 100644
--- a/core/modules/views/src/Plugin/views/filter/InOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -32,7 +32,14 @@ class InOperator extends FilterPluginBase {
    * @var array
    * Stores all operations which are available on the form.
    */
-  var $value_options = NULL;
+  protected $valueOptions = NULL;
+
+  /**
+   * The filter title.
+   *
+   * @var string
+   */
+  protected $valueTitle;
 
   /**
    * Overrides \Drupal\views\Plugin\views\filter\FilterPluginBase::init().
@@ -40,8 +47,8 @@ class InOperator extends FilterPluginBase {
   public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
     parent::init($view, $display, $options);
 
-    $this->value_title = $this->t('Options');
-    $this->value_options = NULL;
+    $this->valueTitle = $this->t('Options');
+    $this->valueOptions = NULL;
   }
 
   /**
@@ -53,26 +60,26 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
    * possible.
    *
    * @return
-   *   Return the stored values in $this->value_options if someone expects it.
+   *   Return the stored values in $this->valueOptions if someone expects it.
    */
   public function getValueOptions() {
-    if (isset($this->value_options)) {
+    if (isset($this->valueOptions)) {
       return;
     }
 
     if (isset($this->definition['options callback']) && is_callable($this->definition['options callback'])) {
       if (isset($this->definition['options arguments']) && is_array($this->definition['options arguments'])) {
-        $this->value_options = call_user_func_array($this->definition['options callback'], $this->definition['options arguments']);
+        $this->valueOptions = call_user_func_array($this->definition['options callback'], $this->definition['options arguments']);
       }
       else {
-        $this->value_options = call_user_func($this->definition['options callback']);
+        $this->valueOptions = call_user_func($this->definition['options callback']);
       }
     }
     else {
-      $this->value_options = array(t('Yes'), $this->t('No'));
+      $this->valueOptions = array(t('Yes'), $this->t('No'));
     }
 
-    return $this->value_options;
+    return $this->valueOptions;
   }
 
   public function defaultExposeOptions() {
@@ -177,7 +184,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
     }
 
     $this->getValueOptions();
-    $options += $this->value_options;
+    $options += $this->valueOptions;
     $default_value = (array) $this->value;
 
     $which = 'all';
@@ -221,7 +228,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
     if ($which == 'all' || $which == 'value') {
       $form['value'] = array(
         '#type' => $this->valueFormType,
-        '#title' => $this->value_title,
+        '#title' => $this->valueTitle,
         '#options' => $options,
         '#default_value' => $default_value,
         // These are only valid for 'select' type, but do no harm to checkboxes.
@@ -254,7 +261,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    */
   public function reduceValueOptions($input = NULL) {
     if (!isset($input)) {
-      $input = $this->value_options;
+      $input = $this->valueOptions;
     }
 
     // Because options may be an array of strings, or an array of mixed arrays
@@ -332,7 +339,7 @@ public function adminSummary() {
     if (in_array($this->operator, $this->operatorValues(1))) {
       // Remove every element which is not known.
       foreach ($this->value as $value) {
-        if (!isset($this->value_options[$value])) {
+        if (!isset($this->valueOptions[$value])) {
           unset($this->value[$value]);
         }
       }
@@ -348,8 +355,8 @@ public function adminSummary() {
 
         $keys = $this->value;
         $value = array_shift($keys);
-        if (isset($this->value_options[$value])) {
-          $values = UtilityString::checkPlain($this->value_options[$value]);
+        if (isset($this->valueOptions[$value])) {
+          $values = UtilityString::checkPlain($this->valueOptions[$value]);
         }
         else {
           $values = '';
@@ -364,8 +371,8 @@ public function adminSummary() {
             $values = Unicode::truncate($values, 8, FALSE, TRUE);
             break;
           }
-          if (isset($this->value_options[$value])) {
-            $values .= UtilityString::checkPlain($this->value_options[$value]);
+          if (isset($this->valueOptions[$value])) {
+            $values .= UtilityString::checkPlain($this->valueOptions[$value]);
           }
         }
       }
@@ -418,7 +425,7 @@ public function validate() {
       $errors[] = $this->t('The operator is invalid on filter: @filter.', array('@filter' => $this->adminLabel(TRUE)));
     }
     if (is_array($this->value)) {
-      if (!isset($this->value_options)) {
+      if (!isset($this->valueOptions)) {
         // Don't validate if there are none value options provided, for example for special handlers.
         return $errors;
       }
@@ -428,7 +435,7 @@ public function validate() {
       }
 
       // Some filter_in_operator usage uses optgroups forms, so flatten it.
-      $flat_options = form_options_flatten($this->value_options, TRUE);
+      $flat_options = form_options_flatten($this->valueOptions, TRUE);
 
       // Remove every element which is not known.
       foreach ($this->value as $value) {
diff --git a/core/modules/views/src/Plugin/views/filter/LanguageFilter.php b/core/modules/views/src/Plugin/views/filter/LanguageFilter.php
index ba7ac15ca6d7..45d36baffe57 100644
--- a/core/modules/views/src/Plugin/views/filter/LanguageFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/LanguageFilter.php
@@ -23,9 +23,9 @@ class LanguageFilter extends InOperator {
    * {@inheritdoc}
    */
   public function getValueOptions() {
-    if (!isset($this->value_options)) {
-      $this->value_title = $this->t('Language');
-      $this->value_options = $this->listLanguages(LanguageInterface::STATE_ALL |LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED);
+    if (!isset($this->valueOptions)) {
+      $this->valueTitle = $this->t('Language');
+      $this->valueOptions = $this->listLanguages(LanguageInterface::STATE_ALL |LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED);
     }
   }
 }
diff --git a/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php b/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php
index 98cc2e512dd5..cde6f751394c 100644
--- a/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php
+++ b/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php
@@ -75,7 +75,7 @@ public function testFilterEntity() {
     // Test we have all the results, with all types selected.
     $this->assertEqual(count($view->result), $this->entities['count']);
 
-    // Test the value_options of the filter handler.
+    // Test the valueOptions of the filter handler.
     $expected = array();
 
     foreach ($this->entityBundles as $key => $info) {
-- 
GitLab