You are here

public function TeamContextManager::getCorrespondingRouteNameForEntity in Apigee Edge 8

Gets the corresponding route name for the given entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The developer or team entity.

Return value

null|string The corresponding route name if one is detected.

Overrides TeamContextManagerInterface::getCorrespondingRouteNameForEntity

1 call to TeamContextManager::getCorrespondingRouteNameForEntity()
TeamContextManager::getDestinationUrlForEntity in modules/apigee_edge_teams/src/TeamContextManager.php
Returns the destination url for the given entity.

File

modules/apigee_edge_teams/src/TeamContextManager.php, line 90

Class

TeamContextManager
Describes the `apigee_edge_teams.context_manager` service.

Namespace

Drupal\apigee_edge_teams

Code

public function getCorrespondingRouteNameForEntity(EntityInterface $entity) : ?string {
  if ($current_route_object = $this->routeMatch
    ->getRouteObject()) {

    // If the route has same parameter type as entity, return current route.
    if ($this->routeMatch
      ->getRawParameters()
      ->has($entity
      ->getEntityTypeId())) {
      return $this->routeMatch
        ->getRouteName();
    }

    // Otherwise return the corresponding route if set.
    return $current_route_object
      ->getOption(static::DEVELOPER_ROUTE_OPTION_NAME) ?? $current_route_object
      ->getOption(static::TEAM_ROUTE_OPTION_NAME);
  }
  return NULL;
}