function yamlform_help in YAML Form 8
Implements hook_help().
File
- ./
yamlform.module, line 35 - Enables the creation of forms and questionnaires.
Code
function yamlform_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',
]) && strpos($route_name, 'yamlform') === FALSE && strpos($path, '/yamlform') === FALSE) {
return NULL;
}
/** @var \Drupal\yamlform\YamlFormHelpManagerInterface $help_manager */
$help_manager = \Drupal::service('yamlform.help_manager');
if ($route_name == 'help.page.yamlform') {
$build = $help_manager
->buildIndex();
}
else {
$build = $help_manager
->buildHelp($route_name, $route_match);
}
if ($build) {
$renderer = \Drupal::service('renderer');
$config = \Drupal::config('yamlform.settings');
$renderer
->addCacheableDependency($build, $config);
return $build;
}
else {
return NULL;
}
}