You are here

public static function WebformShareAccess::checkAccess in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_share/src/Access/WebformShareAccess.php \Drupal\webform_share\Access\WebformShareAccess::checkAccess()

Check whether the webform can be shared and it is not a template.

Parameters

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

Return value

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

1 string reference to 'WebformShareAccess::checkAccess'
webform_share.routing.yml in modules/webform_share/webform_share.routing.yml
modules/webform_share/webform_share.routing.yml

File

modules/webform_share/src/Access/WebformShareAccess.php, line 25

Class

WebformShareAccess
Defines the custom access control handler for webform sharing.

Namespace

Drupal\webform_share\Access

Code

public static function checkAccess(WebformInterface $webform) {
  $share = $webform
    ->getSetting('share', TRUE);
  $share_node = \Drupal::moduleHandler()
    ->moduleExists('webform_node') && $webform
    ->getSetting('share_node', TRUE);
  $template = $webform
    ->isTemplate();
  return AccessResult::allowedIf(($share || $share_node) && !$template)
    ->addCacheTags([
    'config:webform.settings',
  ])
    ->addCacheableDependency($webform);
}