public function YamlFormHelpManager::buildHelp in YAML Form 8
Build help for specific route.
Parameters
string $route_name: The route for which to find help.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match object from which to find help.
Return value
array An render array containing help for specific route.
Overrides YamlFormHelpManagerInterface::buildHelp
File
- src/
YamlFormHelpManager.php, line 133
Class
- YamlFormHelpManager
- Form help manager.
Namespace
Drupal\yamlformCode
public function buildHelp($route_name, RouteMatchInterface $route_match) {
// Get path from route match.
$path = preg_replace('/^' . preg_quote(base_path(), '/') . '/', '/', Url::fromRouteMatch($route_match)
->setAbsolute(FALSE)
->toString());
$build = [];
foreach ($this->help as $id => $help) {
// Set default values.
$help += [
'routes' => [],
'paths' => [],
'access' => TRUE,
'message_type' => '',
'message_close' => FALSE,
'message_id' => '',
'message_storage' => '',
'video_id' => '',
];
if (!$help['access']) {
continue;
}
$is_route_match = in_array($route_name, $help['routes']);
$is_path_match = $help['paths'] && $this->pathMatcher
->matchPath($path, implode("\n", $help['paths']));
$has_help = $is_route_match || $is_path_match;
if (!$has_help) {
continue;
}
if ($help['message_type']) {
$build[$id] = [
'#type' => 'yamlform_message',
'#message_type' => $help['message_type'],
'#message_close' => $help['message_close'],
'#message_id' => $help['message_id'] ? $help['message_id'] : 'yamlform.help.' . $help['id'],
'#message_storage' => $help['message_storage'],
'#message_message' => [
'#theme' => 'yamlform_help',
'#info' => $help,
],
];
if ($help['message_close']) {
$build['#cache']['max-age'] = 0;
}
}
else {
$build[$id] = [
'#theme' => 'yamlform_help',
'#info' => $help,
];
}
}
return $build;
}