You are here

function webform_help in Webform 8.5

Same name and namespace in other branches
  1. 5.2 webform.module \webform_help()
  2. 5 webform.module \webform_help()
  3. 6.3 webform.module \webform_help()
  4. 6.2 webform.module \webform_help()
  5. 7.4 webform.module \webform_help()
  6. 7.3 webform.module \webform_help()
  7. 6.x webform.module \webform_help()

Implements hook_help().

2 string references to 'webform_help'
WebformBreadcrumbBuilder::applies in src/Breadcrumb/WebformBreadcrumbBuilder.php
Whether this breadcrumb builder should be used to build the breadcrumb.
WebformBreadcrumbBuilder::build in src/Breadcrumb/WebformBreadcrumbBuilder.php
Builds the breadcrumb.

File

./webform.module, line 41
Enables the creation of webforms and questionnaires.

Code

function webform_help($route_name, RouteMatchInterface $route_match) {

  // Get path from route match.
  $path = preg_replace('/^' . preg_quote(base_path(), '/') . '/', '/', Url::fromRouteMatch($route_match)
    ->setAbsolute(FALSE)
    ->toString());
  if (!in_array($route_name, [
    'system.modules_list',
    'update.status',
  ]) && strpos($route_name, 'webform') === FALSE && strpos($path, '/webform') === FALSE) {
    return NULL;
  }

  /** @var \Drupal\webform\WebformHelpManagerInterface $help_manager */
  $help_manager = \Drupal::service('webform.help_manager');
  if ($route_name === 'help.page.webform') {
    $build = $help_manager
      ->buildIndex();
  }
  else {
    $build = $help_manager
      ->buildHelp($route_name, $route_match);
  }
  if ($build) {
    $renderer = \Drupal::service('renderer');
    $config = \Drupal::config('webform.settings');
    $renderer
      ->addCacheableDependency($build, $config);
    return $build;
  }
  else {
    return NULL;
  }
}