function WorkflowTypeBase::getTransitionsForState

Same name and namespace in other branches
  1. 9 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getTransitionsForState()
  2. 8.9.x core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getTransitionsForState()
  3. 10 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getTransitionsForState()

Gets the transitions for a state for the provided direction.

Parameters

string $state_id: The state to get transitions for.

string $direction: (optional) The direction of the transition, defaults to TransitionInterface::DIRECTION_FROM. Possible values are: TransitionInterface::DIRECTION_FROM or TransitionInterface::DIRECTION_TO.

Return value

\Drupal\workflows\TransitionInterface[] An array of the transition objects for the state in the given direction, keyed by transition ID.

Overrides WorkflowTypeInterface::getTransitionsForState

File

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

Class

WorkflowTypeBase
A base class for Workflow type plugins.

Namespace

Drupal\workflows\Plugin

Code

public function getTransitionsForState($state_id, $direction = TransitionInterface::DIRECTION_FROM) {
  $transition_ids = array_keys(array_filter($this->configuration['transitions'], function ($transition) use ($state_id, $direction) {
    return in_array($state_id, (array) $transition[$direction], TRUE);
  }));
  return $this->getTransitions($transition_ids);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.