StateTransitionValidation::isTransitionAllowed

public StateTransitionValidation::isTransitionAllowed(ModerationStateInterface $from, ModerationStateInterface $to)

Determines a transition allowed.

Parameters

\Drupal\content_moderation\ModerationStateInterface $from: The origin state.

\Drupal\content_moderation\ModerationStateInterface $to: The destination state.

Return value

bool Is the transition allowed.

Overrides StateTransitionValidationInterface::isTransitionAllowed

File

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

Class

StateTransitionValidation
Validates whether a certain state transition is allowed.

Namespace

Drupal\content_moderation

Code

public function isTransitionAllowed(ModerationStateInterface $from, ModerationStateInterface $to) {
  $allowed_transitions = $this->calculatePossibleTransitions();
  if (isset($allowed_transitions[$from->id()])) {
    return in_array($to->id(), $allowed_transitions[$from->id()], TRUE);
  }
  return FALSE;
}
doc_Drupal
2016-10-29 09:44:18
Comments
Leave a Comment

Please login to continue.