class StateTransitionValidation implements StateTransitionValidationInterface (View source)

Validates whether a certain state transition is allowed.

Properties

protected ModerationInformationInterface $moderationInfo

The moderation information service.

protected array $possibleTransitions

Stores the possible state transitions.

Methods

__construct(ModerationInformationInterface $moderation_info)

Constructs a new StateTransitionValidation.

getValidTransitions(ContentEntityInterface $entity, AccountInterface $user)

Gets a list of transitions that are legal for this user on this entity.

bool
isTransitionValid(WorkflowInterface $workflow, StateInterface $original_state, StateInterface $new_state, AccountInterface $user, ContentEntityInterface $entity)

Checks if a transition between two states if valid for the given user.

Details

__construct(ModerationInformationInterface $moderation_info)

Constructs a new StateTransitionValidation.

Parameters

ModerationInformationInterface $moderation_info

The moderation information service.

Transition[] getValidTransitions(ContentEntityInterface $entity, AccountInterface $user)

Gets a list of transitions that are legal for this user on this entity.

Parameters

ContentEntityInterface $entity

The entity to be transitioned.

AccountInterface $user

The account that wants to perform a transition.

Return Value

Transition[]

The list of transitions that are legal for this user on this entity.

bool isTransitionValid(WorkflowInterface $workflow, StateInterface $original_state, StateInterface $new_state, AccountInterface $user, ContentEntityInterface $entity)

Checks if a transition between two states if valid for the given user.

Parameters

WorkflowInterface $workflow

The workflow entity.

StateInterface $original_state

The original workflow state.

StateInterface $new_state

The new workflow state.

AccountInterface $user

The user to validate.

ContentEntityInterface $entity

The entity to be transitioned.

Return Value

bool

Returns TRUE if transition is valid, otherwise FALSE.