Skip to content
Snippets Groups Projects

3521903: convert views filter options labels to string

1 file
+ 8
21
Compare changes
  • Side-by-side
  • Inline
@@ -3,9 +3,7 @@
namespace Drupal\workflow\Plugin\views\filter;
use Drupal\views\FieldAPIHandlerTrait;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\filter\ManyToOne;
use Drupal\views\ViewExecutable;
/**
* Filter handler which uses workflow_state as options.
@@ -18,16 +16,6 @@ class WorkflowState extends ManyToOne {
use FieldAPIHandlerTrait;
/**
* {@inheritdoc}
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$wid = $this->definition['wid'] ?? '';
$grouped = ($options['group_info']['widget'] ?? '') == 'select';
$this->valueOptions = workflow_allowed_workflow_state_names($wid, $grouped);
}
/**
* Returns the valid options for this State.
*
@@ -42,16 +30,15 @@ class WorkflowState extends ManyToOne {
* The stored values from $this->valueOptions.
*/
public function getValueOptions() {
if (isset($this->valueOptions)) {
return $this->valueOptions;
if (!isset($this->valueOptions)) {
$wid = $this->definition['wid'] ?? '';
$grouped = ($options['group_info']['widget'] ?? '') == 'select';
$this->valueOptions = workflow_allowed_workflow_state_names($wid, $grouped);
array_walk($this->valueOptions, function (&$item) {
$item = (string) $item;
});
}
// @todo Implement the below code, and remove the line from init.
// @todo Follow Options patterns.
// @see callback_allowed_values_function()
// @see options_allowed_values()
return parent::getValueOptions();
return $this->valueOptions;
}
}
Loading