You are here

protected function PostAccessControlHandler::checkDefaultAccess in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  2. 8.2 modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  3. 8.3 modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  4. 8.4 modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  5. 8.5 modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  6. 8.6 modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  7. 8.7 modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  8. 8.8 modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  9. 10.3.x modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  10. 10.0.x modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  11. 10.1.x modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
  12. 10.2.x modules/social_features/social_post/src/PostAccessControlHandler.php \Drupal\social_post\PostAccessControlHandler::checkDefaultAccess()
1 call to PostAccessControlHandler::checkDefaultAccess()
PostAccessControlHandler::checkAccess in modules/social_features/social_post/src/PostAccessControlHandler.php
Performs access checks.

File

modules/social_features/social_post/src/PostAccessControlHandler.php, line 110

Class

PostAccessControlHandler
Access controller for the Post entity.

Namespace

Drupal\social_post

Code

protected function checkDefaultAccess(EntityInterface $entity, $operation, AccountInterface $account) {
  switch ($operation) {
    case 'view':
      if (!$entity
        ->isPublished()) {
        return AccessResult::allowedIfHasPermission($account, 'view unpublished post entities');
      }
      return AccessResult::allowedIfHasPermission($account, 'view published post entities');
    case 'update':
      return AccessResult::allowedIfHasPermission($account, 'edit any post entities');
    case 'delete':
      return AccessResult::allowedIfHasPermission($account, 'delete any post entities');
  }

  // Unknown operation, no opinion.
  return AccessResult::neutral();
}