function EntityAccess::bypassAccessResult
Same name in other branches
- 9 core/modules/workspaces/src/EntityAccess.php \Drupal\workspaces\EntityAccess::bypassAccessResult()
- 8.9.x core/modules/workspaces/src/EntityAccess.php \Drupal\workspaces\EntityAccess::bypassAccessResult()
- 10 core/modules/workspaces/src/EntityAccess.php \Drupal\workspaces\EntityAccess::bypassAccessResult()
Checks the 'bypass' permissions.
Parameters
\Drupal\Core\Session\AccountInterface $account: The user account making the to check access for.
Return value
\Drupal\Core\Access\AccessResult The result of the access check.
2 calls to EntityAccess::bypassAccessResult()
- EntityAccess::entityCreateAccess in core/
modules/ workspaces/ src/ EntityAccess.php - Implements a hook bridge for hook_entity_create_access().
- EntityAccess::entityOperationAccess in core/
modules/ workspaces/ src/ EntityAccess.php - Implements a hook bridge for hook_entity_access().
File
-
core/
modules/ workspaces/ src/ EntityAccess.php, line 142
Class
- EntityAccess
- Service wrapper for hooks relating to entity access control.
Namespace
Drupal\workspacesCode
protected function bypassAccessResult(AccountInterface $account) {
// This approach assumes that the current "global" active workspace is
// correct, i.e. if you're "in" a given workspace then you get ALL THE PERMS
// to ALL THE THINGS! That's why this is a dangerous permission.
$active_workspace = $this->workspaceManager
->getActiveWorkspace();
return AccessResult::allowedIf($active_workspace->getOwnerId() == $account->id())
->cachePerUser()
->addCacheableDependency($active_workspace)
->andIf(AccessResult::allowedIfHasPermission($account, 'bypass entity access own workspace'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.