You are here

public static function WebformEntityAccess::checkLogAccess in Webform 8.5

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

Check whether the webform has log.

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 string reference to 'WebformEntityAccess::checkLogAccess'
webform_submission_log.routing.yml in modules/webform_submission_log/webform_submission_log.routing.yml
modules/webform_submission_log/webform_submission_log.routing.yml

File

src/Access/WebformEntityAccess.php, line 82

Class

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

Namespace

Drupal\webform\Access

Code

public static function checkLogAccess(WebformInterface $webform = NULL, EntityInterface $source_entity = NULL) {

  // ISSUE:
  // Devel routes do not use 'webform' parameter which throws the below error.
  // Some mandatory parameters are missing ("webform") to generate a URL for
  // route "entity.webform_submission.canonical"
  //
  // WORKAROUND:
  // Make sure webform parameter is set for all routes.
  // @see webform_menu_local_tasks_alter()
  if (!$webform && ($webform_submission = \Drupal::routeMatch()
    ->getParameter('webform_submission'))) {
    $webform = $webform_submission
      ->getWebform();
  }
  if (!$webform
    ->hasSubmissionLog()) {
    $access_result = AccessResult::forbidden()
      ->addCacheableDependency($webform);
  }
  else {
    $access_result = static::checkResultsAccess($webform, $source_entity);
  }
  return $access_result
    ->addCacheTags([
    'config:webform.settings',
  ]);
}