You are here

private function SchedulerModerationConstraintValidator::isValidTransition in Scheduler content moderation integration 8

Checks if it's a valid moderation states transition for provided entity.

Parameters

string $moderation_state: The moderation state to validate transition for.

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to check the state against.

Return value

bool TRUE if is a valid transition, FALSE otherwise.

1 call to SchedulerModerationConstraintValidator::isValidTransition()
SchedulerModerationConstraintValidator::validate in src/Plugin/Validation/Constraint/SchedulerModerationConstraintValidator.php
Checks if the passed value is valid.

File

src/Plugin/Validation/Constraint/SchedulerModerationConstraintValidator.php, line 104

Class

SchedulerModerationConstraintValidator
Validates the SchedulerModeration constraint.

Namespace

Drupal\scheduler_content_moderation_integration\Plugin\Validation\Constraint

Code

private function isValidTransition($moderation_state, ContentEntityInterface $entity) {
  $valid_transitions = $this->stateTransitionValidation
    ->getValidTransitions($entity, $this->account);
  foreach ($valid_transitions as $valid_transition) {
    if ($moderation_state === $valid_transition
      ->to()
      ->id()) {
      return TRUE;
    }
  }
  return FALSE;
}