public function ContentSyncHelpManager::buildHelp in Content Synchronization 8.2
Same name and namespace in other branches
- 8 src/ContentSyncHelpManager.php \Drupal\content_sync\ContentSyncHelpManager::buildHelp()
- 3.0.x src/ContentSyncHelpManager.php \Drupal\content_sync\ContentSyncHelpManager::buildHelp()
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 ContentSyncHelpManagerInterface::buildHelp
File
- src/
ContentSyncHelpManager.php, line 112
Class
- ContentSyncHelpManager
- Content Sync help manager.
Namespace
Drupal\content_syncCode
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(PHP_EOL, $help['paths']));
$has_help = $is_route_match || $is_path_match;
if (!$has_help) {
continue;
}
if ($help['message_type']) {
$build[$id] = [
'#type' => 'content_sync_message',
'#message_type' => $help['message_type'],
'#message_close' => $help['message_close'],
'#message_id' => $help['message_id'] ? $help['message_id'] : 'content_sync.help.' . $help['id'],
'#message_storage' => $help['message_storage'],
'#message_message' => [
'#theme' => 'content_sync_help',
'#info' => $help,
],
];
if ($help['message_close']) {
$build['#cache']['max-age'] = 0;
}
}
else {
$build[$id] = [
'#theme' => 'content_sync_help',
'#info' => $help,
];
}
}
return $build;
}