This repository has been archived on 2025-01-19. 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/Access/WebformSubmissionAccess.php
2018-11-23 12:29:20 +00:00

48 lines
1.5 KiB
PHP

<?php
namespace Drupal\webform\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\webform\WebformSubmissionInterface;
/**
* Defines the custom access control handler for the webform submission entities.
*/
class WebformSubmissionAccess {
/**
* Check whether a webform submissions' webform has wizard pages.
*
* @param \Drupal\webform\WebformSubmissionInterface $webform_submission
* A webform submission.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkWizardPagesAccess(WebformSubmissionInterface $webform_submission) {
$condition = $webform_submission->getWebform()->hasWizardPages();
return AccessResult::allowedIf($condition);
}
/**
* Check that webform submission has (email) messages and the user can update any webform submission.
*
* @param \Drupal\webform\WebformSubmissionInterface $webform_submission
* A webform submission.
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkResendAccess(WebformSubmissionInterface $webform_submission, AccountInterface $account) {
if ($webform_submission->getWebform()->hasMessageHandler()) {
return AccessResult::allowed();
}
else {
return AccessResult::forbidden();
}
}
}