protected function ConstraintValidatorBase::isValidTransition in Scheduler content moderation integration 8
Validate transition.
Validate that the transition between the supplied states is a valid transition for the supplied entity.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity containing the workflow to check against.
string $from_state: The state to transition from.
string $to_state: The state to transition to.
Return value
bool TRUE if it's a valid transition. FALSE, otherwise.
3 calls to ConstraintValidatorBase::isValidTransition()
- PublishStateConstraintValidator::validate in src/
Plugin/ Validation/ Constraint/ PublishStateConstraintValidator.php - Checks if the passed value is valid.
- TransitionAccessConstraintValidator::validate in src/
Plugin/ Validation/ Constraint/ TransitionAccessConstraintValidator.php - Checks if the passed value is valid.
- UnPublishStateConstraintValidator::validate in src/
Plugin/ Validation/ Constraint/ UnPublishStateConstraintValidator.php - Checks if the passed value is valid.
File
- src/
Plugin/ Validation/ Constraint/ ConstraintValidatorBase.php, line 90
Class
- ConstraintValidatorBase
- Base class for Scheduler Content Moderation Integration validators.
Namespace
Drupal\scheduler_content_moderation_integration\Plugin\Validation\ConstraintCode
protected function isValidTransition(ContentEntityInterface $entity, $from_state, $to_state) {
$workflow_type = $this
->getEntityWorkflowType($entity);
if (!$workflow_type
->hasState($from_state) || !$workflow_type
->hasState($to_state)) {
return FALSE;
}
$from = $workflow_type
->getState($from_state);
return $from
->canTransitionTo($to_state);
}