public function StateTransitionValidation::userMayTransition in Workbench Moderation 8
Same name and namespace in other branches
- 8.2 src/StateTransitionValidation.php \Drupal\workbench_moderation\StateTransitionValidation::userMayTransition()
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
string $from: The origin state machine name.
string $to: The desetination state machine name.
\Drupal\Core\Session\AccountInterface $user: The user to validate.
Return value
bool TRUE if the given user may transition between those two states.
1 call to StateTransitionValidation::userMayTransition()
- StateTransitionValidation::getValidTransitionTargets in src/
StateTransitionValidation.php - Gets a list of states a user may transition an entity to.
File
- src/
StateTransitionValidation.php, line 180
Class
- StateTransitionValidation
- Validates whether a certain state transition is allowed.
Namespace
Drupal\workbench_moderationCode
public function userMayTransition($from, $to, AccountInterface $user) {
if ($transition = $this
->getTransitionFromStates($from, $to)) {
return $user
->hasPermission('use ' . $transition
->id() . ' transition');
}
return FALSE;
}