You are here

public function Workflow::findTransition in State Machine 8

Finds the workflow transition for moving between two given states.

Parameters

string $from_state_id: The ID of the "from" state.

string $to_state_id: The ID of the "to" state.

Return value

\Drupal\state_machine\Plugin\Workflow\WorkflowTransition|null The transition, or NULL if not found.

Overrides WorkflowInterface::findTransition

File

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

Class

Workflow
Defines the class for workflows.

Namespace

Drupal\state_machine\Plugin\Workflow

Code

public function findTransition($from_state_id, $to_state_id) {
  foreach ($this
    ->getPossibleTransitions($from_state_id) as $transition) {
    if ($transition
      ->getToState()
      ->getId() == $to_state_id) {
      return $transition;
    }
  }
  return NULL;
}