function WorkflowAccessControlHandler::checkAccess
Same name in other branches
- 9 core/modules/workflows/src/WorkflowAccessControlHandler.php \Drupal\workflows\WorkflowAccessControlHandler::checkAccess()
- 8.9.x core/modules/workflows/src/WorkflowAccessControlHandler.php \Drupal\workflows\WorkflowAccessControlHandler::checkAccess()
- 11.x core/modules/workflows/src/WorkflowAccessControlHandler.php \Drupal\workflows\WorkflowAccessControlHandler::checkAccess()
Overrides EntityAccessControlHandler::checkAccess
File
-
core/
modules/ workflows/ src/ WorkflowAccessControlHandler.php, line 54
Class
- WorkflowAccessControlHandler
- Access controller for the Workflow entity.
Namespace
Drupal\workflowsCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\workflows\Entity\Workflow $entity */
$workflow_type = $entity->getTypePlugin();
if (str_starts_with($operation, 'delete-state')) {
[
,
$state_id,
] = explode(':', $operation, 2);
// Deleting a state is editing a workflow, but also we should forbid
// access if there is only one state.
return AccessResult::allowedIf(count($entity->getTypePlugin()
->getStates()) > 1)
->andIf(parent::checkAccess($entity, 'edit', $account))
->andIf(AccessResult::allowedIf(!in_array($state_id, $workflow_type->getRequiredStates(), TRUE)))
->addCacheableDependency($entity);
}
return parent::checkAccess($entity, $operation, $account);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.