You are here

public function TeamContextManager::getCurrentContextEntity in Apigee Edge 8

Determines the current context from the route.

Return value

\Drupal\Core\Entity\EntityInterface|null The current entity or NULL.

Overrides TeamContextManagerInterface::getCurrentContextEntity

File

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

Class

TeamContextManager
Describes the `apigee_edge_teams.context_manager` service.

Namespace

Drupal\apigee_edge_teams

Code

public function getCurrentContextEntity() : ?EntityInterface {
  $context = NULL;
  if ($current_route_object = $this->routeMatch
    ->getRouteObject()) {

    // Check for developer/user route.
    if ($current_route_object
      ->hasOption(static::TEAM_ROUTE_OPTION_NAME)) {
      $context = $this->routeMatch
        ->getParameter('user');
    }

    // Check for team route.
    if ($current_route_object
      ->hasOption(static::DEVELOPER_ROUTE_OPTION_NAME)) {
      $context = $this->routeMatch
        ->getParameter('team');
    }
  }
  return $context instanceof EntityInterface ? $context : NULL;
}