function ModerationStateFilter::getValueOptions
Same name in other branches
- 9 core/modules/content_moderation/src/Plugin/views/filter/ModerationStateFilter.php \Drupal\content_moderation\Plugin\views\filter\ModerationStateFilter::getValueOptions()
- 8.9.x core/modules/content_moderation/src/Plugin/views/filter/ModerationStateFilter.php \Drupal\content_moderation\Plugin\views\filter\ModerationStateFilter::getValueOptions()
- 10 core/modules/content_moderation/src/Plugin/views/filter/ModerationStateFilter.php \Drupal\content_moderation\Plugin\views\filter\ModerationStateFilter::getValueOptions()
Overrides InOperator::getValueOptions
File
-
core/
modules/ content_moderation/ src/ Plugin/ views/ filter/ ModerationStateFilter.php, line 93
Class
- ModerationStateFilter
- Provides a filter for the moderation state of an entity.
Namespace
Drupal\content_moderation\Plugin\views\filterCode
public function getValueOptions() {
if (isset($this->valueOptions)) {
return $this->valueOptions;
}
$this->valueOptions = [];
// Find all workflows which are moderating entity types of the same type the
// view is displaying.
foreach ($this->workflowStorage
->loadByProperties([
'type' => 'content_moderation',
]) as $workflow) {
/** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModerationInterface $workflow_type */
$workflow_type = $workflow->getTypePlugin();
if (in_array($this->getEntityType(), $workflow_type->getEntityTypes(), TRUE)) {
foreach ($workflow_type->getStates() as $state_id => $state) {
$this->valueOptions[$workflow->label()][implode('-', [
$workflow->id(),
$state_id,
])] = $state->label();
}
}
}
return $this->valueOptions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.