You are here

public static function WebformEntityAccess::checkDraftsAccess in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Access/WebformEntityAccess.php \Drupal\webform\Access\WebformEntityAccess::checkDraftsAccess()

Check whether the webform has drafts.

Parameters

\Drupal\webform\WebformInterface $webform: A webform.

\Drupal\Core\Entity\EntityInterface|null $source_entity: The source entity.

Return value

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

1 call to WebformEntityAccess::checkDraftsAccess()
WebformNodeAccess::checkWebformDraftsAccess in modules/webform_node/src/Access/WebformNodeAccess.php
Check whether the user can access a node's webform drafts.
1 string reference to 'WebformEntityAccess::checkDraftsAccess'
webform.routing.yml in ./webform.routing.yml
webform.routing.yml

File

src/Access/WebformEntityAccess.php, line 25

Class

WebformEntityAccess
Defines the custom access control handler for the webform entities.

Namespace

Drupal\webform\Access

Code

public static function checkDraftsAccess(WebformInterface $webform, EntityInterface $source_entity = NULL) {
  $draft = $webform
    ->getSetting('draft');
  switch ($draft) {
    case WebformInterface::DRAFT_AUTHENTICATED:
      $access_result = AccessResult::allowedIf(\Drupal::currentUser()
        ->isAuthenticated());
      break;
    case WebformInterface::DRAFT_ALL:
      $access_result = AccessResult::allowed();
      break;
    case WebformInterface::DRAFT_NONE:
    default:
      $access_result = AccessResult::forbidden();
      break;
  }
  return $access_result
    ->addCacheableDependency($webform);
}