You are here

function _metatag_is_entity_route_entity in Metatag 8

A function to determine whether the entity in question is the route entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

Return value

bool The result.

1 call to _metatag_is_entity_route_entity()
metatag_entity_view_alter in ./metatag.module
Implements hook_entity_view_alter().

File

./metatag.module, line 255
Contains metatag.module.

Code

function _metatag_is_entity_route_entity(EntityInterface $entity) : bool {
  $cached_entity_uuid =& drupal_static(__FUNCTION__);
  if (!$cached_entity_uuid) {
    foreach (\Drupal::routeMatch()
      ->getParameters() as $route_parameter) {
      if ($route_parameter instanceof EntityInterface) {
        if ($route_parameter
          ->uuid() === $entity
          ->uuid()) {
          $cached_entity_uuid = $entity
            ->uuid();
        }
      }
    }
  }
  return $cached_entity_uuid === $entity
    ->uuid();
}