You are here

public function WorkflowManager::getGroupedLabels in State Machine 8

Gets the grouped workflow labels.

Parameters

string $entity_type_id: (optional) The entity type id to filter by. If provided, only workflows that belong to groups with the specified entity type will be returned.

Return value

array Keys are group labels, and values are arrays of which the keys are workflow IDs and the values are workflow labels.

Overrides WorkflowManagerInterface::getGroupedLabels

File

src/WorkflowManager.php, line 144

Class

WorkflowManager
Manages discovery and instantiation of workflow plugins.

Namespace

Drupal\state_machine

Code

public function getGroupedLabels($entity_type_id = NULL) {
  $definitions = $this
    ->getSortedDefinitions();
  $group_labels = $this
    ->getGroupLabels($entity_type_id);
  $grouped_definitions = [];
  foreach ($definitions as $id => $definition) {
    $group_id = $definition['group'];
    if (!isset($group_labels[$group_id])) {

      // Don't return workflows for groups ignored due to their entity type.
      continue;
    }
    $group_label = $group_labels[$group_id];
    $grouped_definitions[$group_label][$id] = $definition['label'];
  }
  return $grouped_definitions;
}