function hook_metatag_route_entity in Metatag 8
Provides a ability to integrate alternative routes with metatags.
Return an entity when the given route/route parameters matches a certain entity. All meta tags will be rendered on that page.
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.
Return value
\Drupal\Core\Entity\EntityInterface|null Return an entity, if the route should use metatags.
3 functions implement hook_metatag_route_entity()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- metatag_page_manager_metatag_route_entity in metatag_page_manager/
metatag_page_manager.module - Implements hook_metatag_route_entity().
- metatag_test_custom_route_metatag_route_entity in tests/
modules/ metatag_test_custom_route/ metatag_test_custom_route.module - Implements hook_metatag_route_entity().
- metatag_views_metatag_route_entity in metatag_views/
metatag_views.module - Implements hook_metatag_route_entity().
1 invocation of hook_metatag_route_entity()
- metatag_get_route_entity in ./
metatag.module - Returns the entity of the current route.
File
- ./
metatag.api.php, line 20 - Document all supported APIs.
Code
function hook_metatag_route_entity(\Drupal\Core\Routing\RouteMatchInterface $route_match) {
if ($route_match
->getRouteName() === 'example.test_route') {
if ($node = $route_match
->getParameter('node')) {
return $node;
}
}
}