function WorkflowTypeBase::getTransitionIdFromStateToState

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

Gets the transition ID 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

string|null The transition ID, or NULL if no transition exists.

3 calls to WorkflowTypeBase::getTransitionIdFromStateToState()
WorkflowTypeBase::getTransitionFromStateToState in core/modules/workflows/src/Plugin/WorkflowTypeBase.php
Gets a transition from state to state.
WorkflowTypeBase::hasTransitionFromStateToState in core/modules/workflows/src/Plugin/WorkflowTypeBase.php
Determines if a transition from state to state exists.
WorkflowTypeBase::setTransitionFromStates in core/modules/workflows/src/Plugin/WorkflowTypeBase.php
Sets a transition's from states.

File

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

Class

WorkflowTypeBase
A base class for Workflow type plugins.

Namespace

Drupal\workflows\Plugin

Code

protected function getTransitionIdFromStateToState($from_state_id, $to_state_id) {
    foreach ($this->configuration['transitions'] as $transition_id => $transition) {
        if (in_array($from_state_id, $transition['from'], TRUE) && $transition['to'] === $to_state_id) {
            return $transition_id;
        }
    }
    return NULL;
}

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