You are here

public function Workflow::getPossibleTransitions in State Machine 8

Gets the possible workflow transitions for the given state ID.

Note that a possible transition might not be allowed (because of a guard returning false).

Parameters

string $state_id: The state ID.

Return value

\Drupal\state_machine\Plugin\Workflow\WorkflowTransition[] The possible transitions, keyed by transition ID.

Overrides WorkflowInterface::getPossibleTransitions

2 calls to Workflow::getPossibleTransitions()
Workflow::findTransition in src/Plugin/Workflow/Workflow.php
Finds the workflow transition for moving between two given states.
Workflow::getAllowedTransitions in src/Plugin/Workflow/Workflow.php
Gets the allowed workflow transitions for the given state ID.

File

src/Plugin/Workflow/Workflow.php, line 132

Class

Workflow
Defines the class for workflows.

Namespace

Drupal\state_machine\Plugin\Workflow

Code

public function getPossibleTransitions($state_id) {
  if (empty($state_id)) {
    return $this->transitions;
  }
  $possible_transitions = [];
  foreach ($this->transitions as $id => $transition) {
    if (array_key_exists($state_id, $transition
      ->getFromStates())) {
      $possible_transitions[$id] = $transition;
    }
  }
  return $possible_transitions;
}