StateTransitionValidation::getTransitionFromStates

protected StateTransitionValidation::getTransitionFromStates(ModerationStateInterface $from, ModerationStateInterface $to)

Returns the transition object that transitions from one state to another.

Parameters

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

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

Return value

ModerationStateTransition|null A transition object, or NULL if there is no such transition.

File

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

Class

StateTransitionValidation
Validates whether a certain state transition is allowed.

Namespace

Drupal\content_moderation

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
protected function getTransitionFromStates(ModerationStateInterface $from, ModerationStateInterface $to) {
  $from = $this->transitionStateQuery()
    ->condition('stateFrom', $from->id())
    ->condition('stateTo', $to->id())
    ->execute();
 
  $transitions = $this->transitionStorage()->loadMultiple($from);
 
  if ($transitions) {
    return current($transitions);
  }
  return NULL;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.