protected function WorkflowCollector::mapTransitions in Workbench Moderation to Content Moderation 8.2
Generates Content Moderation-compatible state transition definitions.
Parameters
string[] $states: The moderation state entity IDs for which transition definitions should be generated.
Return value
array The Content Moderation-compatible state transition definitions.
1 call to WorkflowCollector::mapTransitions()
- WorkflowCollector::getWorkflows in src/
WorkflowCollector.php - Returns all unique content type workflows.
File
- src/
WorkflowCollector.php, line 127
Class
Namespace
Drupal\wbm2cmCode
protected function mapTransitions(array $states) {
$excluded_states = array_diff($this->stateStorage
->getQuery()
->execute(), $states);
$transitions = $this->transitionStorage
->getQuery()
->condition('stateFrom', $excluded_states, 'NOT IN')
->condition('stateTo', $excluded_states, 'NOT IN')
->execute();
$weight = 1;
$map = function (ModerationStateTransitionInterface $transition) use (&$weight) {
return [
'label' => $transition
->label(),
'from' => (array) $transition
->getFromState(),
'to' => $transition
->getToState(),
'weight' => $weight++,
];
};
return array_map($map, $this->transitionStorage
->loadMultiple($transitions));
}