VocabularyAccessControlHandler.php 847 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Drupal\taxonomy;
  3. use Drupal\Core\Access\AccessResult;
  4. use Drupal\Core\Entity\EntityAccessControlHandler;
  5. use Drupal\Core\Entity\EntityInterface;
  6. use Drupal\Core\Session\AccountInterface;
  7. /**
  8. * Defines the access control handler for the taxonomy vocabulary entity type.
  9. *
  10. * @see \Drupal\taxonomy\Entity\Vocabulary
  11. */
  12. class VocabularyAccessControlHandler extends EntityAccessControlHandler {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
  17. switch ($operation) {
  18. case 'access taxonomy overview':
  19. case 'view':
  20. return AccessResult::allowedIfHasPermissions($account, ['access taxonomy overview', 'administer taxonomy'], 'OR');
  21. default:
  22. return parent::checkAccess($entity, $operation, $account);
  23. }
  24. }
  25. }