This repository has been archived on 2025-09-29. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
drupalcampbristol/web/modules/contrib/webform/src/WebformSubmissionAccessControlHandler.php
2017-03-16 15:29:07 +00:00

35 lines
1.1 KiB
PHP

<?php
namespace Drupal\webform;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
/**
* Defines the access control handler for the webform submission entity type.
*
* @see \Drupal\webform\Entity\WebformSubmission.
*/
class WebformSubmissionAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
public function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
// Allow users with 'view any webform submission' to view all submissions.
if ($operation == 'view' && $account->hasPermission('view any webform submission')) {
return AccessResult::allowed();
}
/** @var \Drupal\webform\WebformSubmissionInterface $entity */
$webform = $entity->getWebform();
if ($webform->access('update') || $webform->checkAccessRules($operation, $account, $entity)) {
return AccessResult::allowed();
}
return parent::checkAccess($entity, $operation, $account);
}
}