Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / metatag / metatag.api.php
1 <?php
2
3 /**
4  * @file
5  * Document all supported APIs.
6  */
7
8 /**
9  * Provides a ability to integrate alternative routes with metatags.
10  *
11  * Return an entity when the given route/route parameters matches a certain
12  * entity. All metatags will be rendered on that page.
13  *
14  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
15  *   The route match.
16  *
17  * @return \Drupal\Core\Entity\EntityInterface|null
18  *   Return an entity, if the route should use metatags.
19  */
20 function hook_metatag_route_entity(\Drupal\Core\Routing\RouteMatchInterface $route_match) {
21   if ($route_match->getRouteName() === 'example.test_route') {
22     if ($node = $route_match->getParameter('node')) {
23       return $node;
24     }
25   }
26 }
27
28 /**
29  * Alter the metatags for pages that are not of content entities.
30  *
31  * @param array $metatags
32  *   The special metatags to be added to the page.
33  * @param array $context
34  *   The context, containing the entity used for token replacements.
35  */
36 function hook_metatags_alter(array &$metatags, array $context) {
37   // Exclude metatags on frontpage.
38   if (\Drupal::service('path.matcher')->isFrontPage()) {
39     $metatags = NULL;
40   }
41 }