ContentModerationStateAccessControlHandler.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Drupal\content_moderation;
  3. use Drupal\Core\Access\AccessResult;
  4. use Drupal\Core\Session\AccountInterface;
  5. use Drupal\Core\Entity\EntityAccessControlHandler;
  6. use Drupal\Core\Entity\EntityInterface;
  7. /**
  8. * The access control handler for the content_moderation_state entity type.
  9. *
  10. * @see \Drupal\content_moderation\Entity\ContentModerationState
  11. */
  12. class ContentModerationStateAccessControlHandler extends EntityAccessControlHandler {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
  17. // ContentModerationState is an internal entity type. Access is denied for
  18. // viewing, updating, and deleting. In order to update an entity's
  19. // moderation state use its moderation_state field.
  20. return AccessResult::forbidden('ContentModerationState is an internal entity type.');
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
  26. // ContentModerationState is an internal entity type. Access is denied for
  27. // creating. In order to update an entity's moderation state use its
  28. // moderation_state field.
  29. return AccessResult::forbidden('ContentModerationState is an internal entity type.');
  30. }
  31. }