You are here

public function TeamContextManager::getDestinationUrlForEntity in Apigee Edge 8

Returns the destination url for the given entity.

Parameters

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

Return value

\Drupal\Core\Url|null The destination URL.

Overrides TeamContextManagerInterface::getDestinationUrlForEntity

File

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

Class

TeamContextManager
Describes the `apigee_edge_teams.context_manager` service.

Namespace

Drupal\apigee_edge_teams

Code

public function getDestinationUrlForEntity(EntityInterface $entity) : ?Url {
  if ($corresponding_route_name = $this
    ->getCorrespondingRouteNameForEntity($entity)) {

    // Rebuild parameters for current context.
    $parameters = array_diff_key($this->routeMatch
      ->getRawParameters()
      ->all(), [
      $entity
        ->getEntityTypeId() === 'user' ? 'team' : 'user' => NULL,
    ]);
    $parameters[$entity
      ->getEntityTypeId()] = $entity
      ->id();
    return Url::fromRoute($corresponding_route_name, $parameters);
  }
  return NULL;
}