function lightning_core_help in Lightning Core 8.4
Same name and namespace in other branches
- 8.5 lightning_core.module \lightning_core_help()
- 8 lightning_core.module \lightning_core_help()
- 8.2 lightning_core.module \lightning_core_help()
- 8.3 lightning_core.module \lightning_core_help()
Implements hook_help().
File
- ./
lightning_core.module, line 115 - Contains core functionality for the Lightning distribution.
Code
function lightning_core_help($route_name, RouteMatchInterface $route_match) {
$matched = [];
// Parse the route name to figure out what display mode we're looking at:
// 0 is the entire string.
// 1 is 'view' or 'form'.
// 2 is the ID of the affected entity type.
// 3 is 'view_mode' or 'form_mode'.
// 4 is 'view' or 'form'.
$expr = '/^entity\\.entity_(view|form)_display\\.([a-z_]+)\\.((view|form)_mode)$/';
if (preg_match($expr, $route_name, $matched)) {
$entity_id = sprintf('%s.%s', $route_match
->getParameter('entity_type_id'), $route_match
->getParameter($matched[3] . '_name'));
$display_mode = \Drupal::entityTypeManager()
->getStorage('entity_' . $matched[3])
->load($entity_id);
if ($display_mode instanceof EntityDescriptionInterface) {
$description = $display_mode
->getDescription();
if ($description) {
return '<p>' . $description . '</p>';
}
}
}
}