You are here

class WebformHandlerAccess in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Access/WebformHandlerAccess.php \Drupal\webform\Access\WebformHandlerAccess

Defines the custom access control handler for the webform handlers.

Hierarchy

Expanded class hierarchy of WebformHandlerAccess

File

src/Access/WebformHandlerAccess.php, line 10

Namespace

Drupal\webform\Access
View source
class WebformHandlerAccess {

  /**
   * Check whether the webform handler is enabled.
   *
   * @param string $webform_handler
   *   A webform handler id.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public static function checkHandlerAccess($webform_handler = NULL) {

    /** @var \Drupal\webform\Plugin\WebformHandlerManagerInterface $handler_manager */
    $handler_manager = \Drupal::service('plugin.manager.webform.handler');
    $handler_definitions = $handler_manager
      ->getDefinitions();
    $handler_definitions = $handler_manager
      ->removeExcludeDefinitions($handler_definitions);
    if ($webform_handler) {
      $access_result = AccessResult::allowedIf(!empty($handler_definitions[$webform_handler]));
    }
    else {
      unset($handler_definitions['broken'], $handler_definitions['email']);
      $access_result = AccessResult::allowedIf(!empty($handler_definitions));
    }
    return $access_result
      ->addCacheTags([
      'config:webform.settings',
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WebformHandlerAccess::checkHandlerAccess public static function Check whether the webform handler is enabled.