You are here

public static function YamlFormAccess::checkEmailAccess in YAML Form 8

Check that form submission has email and the user can update any form submission.

Parameters

\Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission: A form submission.

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 string reference to 'YamlFormAccess::checkEmailAccess'
yamlform.routing.yml in ./yamlform.routing.yml
yamlform.routing.yml

File

src/Access/YamlFormAccess.php, line 66

Class

YamlFormAccess
Defines the custom access control handler for the form entities.

Namespace

Drupal\yamlform\Access

Code

public static function checkEmailAccess(YamlFormSubmissionInterface $yamlform_submission, AccountInterface $account) {
  $yamlform = $yamlform_submission
    ->getYamlForm();
  if ($yamlform
    ->access('submission_update_any')) {
    $handlers = $yamlform
      ->getHandlers();
    foreach ($handlers as $handler) {
      if ($handler instanceof YamlFormHandlerMessageInterface) {
        return AccessResult::allowed();
      }
    }
  }
  return AccessResult::forbidden();
}