protected function IngredientAccessControlHandler::checkAccess in Recipe 8.2
Link the activities to the permissions. checkAccess is called with the $operation as defined in the routing.yml file.
Overrides EntityAccessControlHandler::checkAccess
File
- modules/
ingredient/ src/ IngredientAccessControlHandler.php, line 21
Class
- IngredientAccessControlHandler
- Access controller for ingredients.
Namespace
Drupal\ingredientCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'view ingredient');
case 'edit':
return AccessResult::allowedIfHasPermission($account, 'edit ingredient');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete ingredient');
}
return AccessResult::allowed();
}