function StateTransitionValidation::isTransitionValid

Same name in other branches
  1. 9 core/modules/content_moderation/src/StateTransitionValidation.php \Drupal\content_moderation\StateTransitionValidation::isTransitionValid()
  2. 8.9.x core/modules/content_moderation/src/StateTransitionValidation.php \Drupal\content_moderation\StateTransitionValidation::isTransitionValid()
  3. 11.x core/modules/content_moderation/src/StateTransitionValidation.php \Drupal\content_moderation\StateTransitionValidation::isTransitionValid()

File

core/modules/content_moderation/src/StateTransitionValidation.php, line 55

Class

StateTransitionValidation
Validates whether a certain state transition is allowed.

Namespace

Drupal\content_moderation

Code

public function isTransitionValid(WorkflowInterface $workflow, StateInterface $original_state, StateInterface $new_state, AccountInterface $user, ContentEntityInterface $entity) {
    $transition = $workflow->getTypePlugin()
        ->getTransitionFromStateToState($original_state->id(), $new_state->id());
    return $user->hasPermission('use ' . $workflow->id() . ' transition ' . $transition->id());
}

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