Commit 1546d71f authored by alexpott's avatar alexpott

Issue #2605214 by Gábor Hojtsy, ChuChuNaKu, EclipseGc, dawehner: Views...

Issue #2605214 by Gábor Hojtsy, ChuChuNaKu, EclipseGc, dawehner: Views InOperator::getValueOptions() children do not return values like InOperator::getValueOptions()
parent bbd1baf2
......@@ -25,6 +25,7 @@ public function getValueOptions() {
CommentItemInterface::CLOSED => $this->t('Closed'),
CommentItemInterface::OPEN => $this->t('Open'),
);
return $this->valueOptions;
}
}
......@@ -22,6 +22,7 @@ public function getValueOptions() {
if (!isset($this->valueOptions)) {
$this->valueOptions = _views_file_status();
}
return $this->valueOptions;
}
}
......@@ -45,6 +45,18 @@ public function testFilter() {
'name' => $name,
));
$this->assertIdenticalResultset($view, $expected, array('views_test_data_name' => 'name'));
$expected = [
'***LANGUAGE_site_default***',
'***LANGUAGE_language_interface***',
'***LANGUAGE_language_content***',
'en',
'xx-lolspeak',
'und',
'zxx'
];
$this->assertIdentical(array_keys($view->filter['langcode']->getValueOptions()), $expected);
$view->destroy();
}
}
......
......@@ -89,7 +89,12 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
public function hasExtraOptions() { return TRUE; }
public function getValueOptions() { /* don't overwrite the value options */ }
/**
* {@inheritdoc}
*/
public function getValueOptions() {
return $this->valueOptions;
}
protected function defineOptions() {
$options = parent::defineOptions();
......
......@@ -101,8 +101,12 @@ protected function valueSubmit($form, FormStateInterface $form_state) {
// prevent array filter from removing our anonymous user.
}
// Override to do nothing.
public function getValueOptions() { }
/**
* {@inheritdoc}
*/
public function getValueOptions() {
return $this->valueOptions;
}
public function adminSummary() {
// set up $this->valueOptions for the parent summary
......
......@@ -78,6 +78,7 @@ public function getValueOptions() {
$display_name = $this->moduleHandler->getName($provider);
$this->valueOptions[$display_name][$perm] = Html::escape(strip_tags($perm_item['title']));
}
return $this->valueOptions;
}
else {
return $this->valueOptions;
......
......@@ -60,6 +60,8 @@ public static function create(ContainerInterface $container, array $configuratio
public function getValueOptions() {
$this->valueOptions = user_role_names(TRUE);
unset($this->valueOptions[RoleInterface::AUTHENTICATED_ID]);
return $this->valueOptions;
}
/**
......
......@@ -74,7 +74,6 @@ public function testFilterPermission() {
$view->initDisplay();
$view->initHandlers();
$view->filter['permission']->getValueOptions();
// Test the value options.
$value_options = $view->filter['permission']->getValueOptions();
......
......@@ -9,6 +9,7 @@
use Drupal\user\Entity\Role;
use Drupal\views\Entity\View;
use Drupal\views\Views;
/**
* Tests the roles filter handler.
......@@ -52,6 +53,11 @@ public function testDependencies() {
$expected['config'][] = 'user.role.test_user_role';
$this->assertEqual($expected, $view->getDependencies());
$view = Views::getView('test_user_name');
$view->initDisplay();
$view->initHandlers();
$this->assertEqual(array_keys($view->filter['roles_target_id']->getValueOptions()), ['test_user_role']);
$view = View::load('test_user_name');
$display = &$view->getDisplay('default');
$display['display_options']['filters']['roles_target_id'] = [
......
......@@ -83,6 +83,8 @@ public function testUserNameApi() {
$this->executeView($view);
$this->assertIdenticalResultset($view, array(array('uid' => $this->accounts[0]->id())), $this->columnMap);
$this->assertEqual($view->filter['uid']->getValueOptions(), NULL);
}
/**
......
......@@ -59,8 +59,8 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
* This can use a guard to be used to reduce database hits as much as
* possible.
*
* @return
* Return the stored values in $this->valueOptions if someone expects it.
* @return array|NULL
* The stored values from $this->valueOptions.
*/
public function getValueOptions() {
if (isset($this->valueOptions)) {
......
......@@ -69,6 +69,7 @@ public function getValueOptions() {
// lost when there are changes in the language configuration.
$this->valueOptions = $this->listLanguages(LanguageInterface::STATE_ALL | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED, array_keys($this->value));
}
return $this->valueOptions;
}
/**
......
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