class WebformSubmissionAccess in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Access/WebformSubmissionAccess.php \Drupal\webform\Access\WebformSubmissionAccess
Defines the custom access control handler for the webform submission entities.
Hierarchy
- class \Drupal\webform\Access\WebformSubmissionAccess
Expanded class hierarchy of WebformSubmissionAccess
2 files declare their use of WebformSubmissionAccess
- WebformNodeAccess.php in modules/
webform_node/ src/ Access/ WebformNodeAccess.php - WebformSubmissionAccessTest.php in tests/
src/ Unit/ Access/ WebformSubmissionAccessTest.php
File
- src/
Access/ WebformSubmissionAccess.php, line 12
Namespace
Drupal\webform\AccessView source
class WebformSubmissionAccess {
/**
* Check whether a webform submissions' webform has wizard pages/cards.
*
* @param \Drupal\webform\WebformSubmissionInterface $webform_submission
* A webform submission.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public static function checkWizardPagesAccess(WebformSubmissionInterface $webform_submission) {
// Check wizard pages.
$has_wizard_pages = $webform_submission
->getWebform()
->hasWizardPages();
// Check cards.
if (\Drupal::moduleHandler()
->moduleExists('webform_cards')) {
/** @var \Drupal\webform_cards\WebformCardsManagerInterface $webform_cards_manager */
$webform_cards_manager = \Drupal::service('webform_cards.manager');
$has_cards = $webform_cards_manager
->hasCards($webform_submission
->getWebform());
}
else {
$has_cards = FALSE;
}
return AccessResult::allowedIf($has_wizard_pages || $has_cards);
}
/**
* 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();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebformSubmissionAccess:: |
public static | function | Check that webform submission has (email) messages and the user can update any webform submission. | |
WebformSubmissionAccess:: |
public static | function | Check whether a webform submissions' webform has wizard pages/cards. |