You are here

public function WorkflowTypeBase::getTransition in Drupal 8

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

Gets a transition object for the provided transition ID.

Parameters

string $transition_id: A transition ID.

Return value

\Drupal\workflows\TransitionInterface The transition.

Throws

\InvalidArgumentException Thrown if $transition_id does not exist.

Overrides WorkflowTypeInterface::getTransition

1 call to WorkflowTypeBase::getTransition()
WorkflowTypeBase::getTransitionFromStateToState in core/modules/workflows/src/Plugin/WorkflowTypeBase.php
Gets a transition from state to state.

File

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

Class

WorkflowTypeBase
A base class for Workflow type plugins.

Namespace

Drupal\workflows\Plugin

Code

public function getTransition($transition_id) {
  if (!$this
    ->hasTransition($transition_id)) {
    throw new \InvalidArgumentException("The transition '{$transition_id}' does not exist in workflow.");
  }
  return new Transition($this, $transition_id, $this->configuration['transitions'][$transition_id]['label'], $this->configuration['transitions'][$transition_id]['from'], $this->configuration['transitions'][$transition_id]['to'], $this->configuration['transitions'][$transition_id]['weight']);
}