You are here

public function WorkflowTypeBase::getTransitionFromStateToState in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getTransitionFromStateToState()

Gets a transition from state to state.

Parameters

string $from_state_id: The state ID to transition from.

string $to_state_id: The state ID to transition to.

Return value

\Drupal\workflows\TransitionInterface The transitions.

Throws

\InvalidArgumentException Thrown if the transition does not exist.

Overrides WorkflowTypeInterface::getTransitionFromStateToState

File

core/modules/workflows/src/Plugin/WorkflowTypeBase.php, line 346

Class

WorkflowTypeBase
A base class for Workflow type plugins.

Namespace

Drupal\workflows\Plugin

Code

public function getTransitionFromStateToState($from_state_id, $to_state_id) {
  $transition_id = $this
    ->getTransitionIdFromStateToState($from_state_id, $to_state_id);
  if (empty($transition_id)) {
    throw new \InvalidArgumentException("The transition from '{$from_state_id}' to '{$to_state_id}' does not exist in workflow.");
  }
  return $this
    ->getTransition($transition_id);
}