You are here

public function WorkflowTypeBase::getTransitionsForState in Drupal 8

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

Gets the transition IDs for a state for the provided direction.

Parameters

$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

array The transition IDs for a state for the provided direction.

Overrides WorkflowTypeInterface::getTransitionsForState

See also

\Drupal\workflows\TransitionInterface::DIRECTION_FROM

\Drupal\workflows\TransitionInterface::DIRECTION_TO

File

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

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);
}