public StateTransitionValidation::userMayTransition(ModerationStateInterface $from, ModerationStateInterface $to, AccountInterface $user)
Determines if a user is allowed to transition from one state to another.
This method will also return FALSE if there is no transition between the specified states at all.
Parameters
\Drupal\content_moderation\ModerationStateInterface $from: The origin state.
\Drupal\content_moderation\ModerationStateInterface $to: The destination state.
\Drupal\Core\Session\AccountInterface $user: The user to validate.
Return value
bool TRUE if the given user may transition between those two states.
Overrides StateTransitionValidationInterface::userMayTransition
File
- core/modules/content_moderation/src/StateTransitionValidation.php, line 159
Class
- StateTransitionValidation
- Validates whether a certain state transition is allowed.
Namespace
Drupal\content_moderation
Code
public function userMayTransition(ModerationStateInterface $from, ModerationStateInterface $to, AccountInterface $user) { if ($transition = $this->getTransitionFromStates($from, $to)) { return $user->hasPermission('use ' . $transition->id() . ' transition'); } return FALSE; }
Please login to continue.