function EntityPermissionsForm::access
Same name and namespace in other branches
- 10 core/modules/user/src/Form/EntityPermissionsForm.php \Drupal\user\Form\EntityPermissionsForm::access()
- 11.x core/modules/user/src/Form/EntityPermissionsForm.php \Drupal\user\Form\EntityPermissionsForm::access()
Checks that there are permissions to be managed.
Parameters
\Symfony\Component\Routing\Route $route: The route to check against.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The parametrized route.
string|EntityInterface $bundle: (optional) The bundle. Different entity types can have different names for their bundle key, so if not specified on the route via a {bundle} parameter, the access checker determines the appropriate key name, and gets the value from the corresponding request attribute. For example, for nodes, the bundle key is "node_type", so the value would be available via the {node_type} parameter rather than a {bundle} parameter.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
File
-
core/
modules/ user/ src/ Form/ EntityPermissionsForm.php, line 155
Class
- EntityPermissionsForm
- Provides the permissions administration form for a bundle.
Namespace
Drupal\user\FormCode
public function access(Route $route, RouteMatchInterface $route_match, $bundle = NULL) : AccessResultInterface {
// Set $this->bundle for use by ::permissionsByProvider().
if ($bundle instanceof EntityInterface) {
$this->bundle = $bundle;
}
else {
$bundle_entity_type = $route->getDefault('bundle_entity_type');
$bundle_name = is_string($bundle) ? $bundle : $route_match->getRawParameter($bundle_entity_type);
$this->bundle = $this->entityTypeManager
->getStorage($bundle_entity_type)
->load($bundle_name);
}
if (empty($this->bundle)) {
// A typo in the request path can lead to this case.
return AccessResult::forbidden();
}
return AccessResult::allowedIf((bool) $this->permissionsByProvider());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.