function ConfigTestRestHooks::configTestAccess
Implements hook_ENTITY_TYPE_access().
File
-
core/
modules/ rest/ tests/ modules/ config_test_rest/ src/ Hook/ ConfigTestRestHooks.php, line 32
Class
- ConfigTestRestHooks
- Hook implementations for config_test_rest.
Namespace
Drupal\config_test_rest\HookCode
public function configTestAccess(EntityInterface $entity, $operation, AccountInterface $account) {
// Add permission, so that EntityResourceTestBase's scenarios can test access
// being denied. By default, all access is always allowed for the config_test
// config entity.
$access_result = AccessResult::forbiddenIf(!$account->hasPermission('view config_test'))
->cachePerPermissions();
if (!$access_result->isAllowed() && $access_result instanceof AccessResultReasonInterface) {
$access_result->setReason("The 'view config_test' permission is required.");
}
return $access_result;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.