Commit 3bb1ac58 authored by alexpott's avatar alexpott
Browse files

Issue #2183421 by alimac, Crisz, InternetDevels, schnippy, evilehk, bender404...

Issue #2183421 by alimac, Crisz, InternetDevels, schnippy, evilehk, bender404 | bohart: In InOperator Rename Views properties to core standards.
parent c76fb28c
......@@ -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'),
......
......@@ -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);
}
}
......@@ -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();
}
}
......
......@@ -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();
......
......@@ -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.
}
}
}
......
......@@ -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;
}
}
......
......@@ -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]);
}
/**
......
......@@ -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() {
......
......@@ -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;
}
/**
......
......@@ -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) {
......
......@@ -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);
}
}
}
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment