protected function SiteSettingEntityAccessControlHandler::checkAccess in Site Settings and Labels 8
Performs access checks.
This method is supposed to be overwritten by extending classes that do their own custom access checking.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for which to check access.
string $operation: The entity operation. Usually one of 'view', 'view label', 'update' or 'delete'.
\Drupal\Core\Session\AccountInterface $account: The user for which to check access.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
Overrides EntityAccessControlHandler::checkAccess
File
- src/
SiteSettingEntityAccessControlHandler.php, line 54
Class
- SiteSettingEntityAccessControlHandler
- Access controller for the Site Setting entity.
Namespace
Drupal\site_settingsCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\site_settings\SiteSettingEntityInterface $entity */
switch ($operation) {
case 'view':
if (!$entity
->isPublished()) {
return AccessResult::allowedIfHasPermission($account, 'view unpublished site setting entities');
}
return AccessResult::allowedIfHasPermission($account, 'view published site setting entities');
case 'update':
return AccessResult::allowedIfHasPermission($account, 'edit site setting entities');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete site setting entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}