You are here

public function Workflow::getAllowedTransitions in State Machine 8

Gets the allowed workflow transitions for the given state ID.

Parameters

string $state_id: The state ID.

\Drupal\Core\Entity\EntityInterface $entity: The parent entity.

Return value

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

Overrides WorkflowInterface::getAllowedTransitions

File

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

Class

Workflow
Defines the class for workflows.

Namespace

Drupal\state_machine\Plugin\Workflow

Code

public function getAllowedTransitions($state_id, EntityInterface $entity) {
  $allowed_transitions = [];
  foreach ($this
    ->getPossibleTransitions($state_id) as $transition_id => $transition) {
    if ($this
      ->isTransitionAllowed($transition, $entity)) {
      $allowed_transitions[$transition_id] = $transition;
    }
  }
  return $allowed_transitions;
}