TermAccessControlHandler.php in Zircon Profile 8
File
core/modules/taxonomy/src/TermAccessControlHandler.php
View source
<?php
namespace Drupal\taxonomy;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
class TermAccessControlHandler extends EntityAccessControlHandler {
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'access content');
break;
case 'update':
return AccessResult::allowedIfHasPermissions($account, [
"edit terms in {$entity->bundle()}",
'administer taxonomy',
], 'OR');
break;
case 'delete':
return AccessResult::allowedIfHasPermissions($account, [
"delete terms in {$entity->bundle()}",
'administer taxonomy',
], 'OR');
break;
default:
return AccessResult::neutral();
}
}
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'administer taxonomy');
}
}