You are here

final class TeamContextSwitcherRouteAlterSubscriber in Apigee Edge 8

Adds the _apigee_team_route option to developer (user) routes.

Hierarchy

Expanded class hierarchy of TeamContextSwitcherRouteAlterSubscriber

See also

\Drupal\apigee_edge_teams\TeamContextManager::getCorrespondingRouteNameForEntity()

1 string reference to 'TeamContextSwitcherRouteAlterSubscriber'
apigee_edge_teams.services.yml in modules/apigee_edge_teams/apigee_edge_teams.services.yml
modules/apigee_edge_teams/apigee_edge_teams.services.yml
1 service uses TeamContextSwitcherRouteAlterSubscriber
route.subscriber.apigee_edge_teams.team_context_switcher in modules/apigee_edge_teams/apigee_edge_teams.services.yml
Drupal\apigee_edge_teams\Routing\TeamContextSwitcherRouteAlterSubscriber

File

modules/apigee_edge_teams/src/Routing/TeamContextSwitcherRouteAlterSubscriber.php, line 32

Namespace

Drupal\apigee_edge_teams\Routing
View source
final class TeamContextSwitcherRouteAlterSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    foreach ($collection as $id => $route) {

      // Add a corresponding team route if the team route defines a
      // corresponding developer route.
      if (($developer_route_id = $route
        ->getOption(TeamContextManagerInterface::DEVELOPER_ROUTE_OPTION_NAME)) && ($developer_route = $collection
        ->get($developer_route_id)) && empty($developer_route
        ->getOption(TeamContextManagerInterface::TEAM_ROUTE_OPTION_NAME))) {
        $developer_route
          ->setOption(TeamContextManagerInterface::TEAM_ROUTE_OPTION_NAME, $id);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1
TeamContextSwitcherRouteAlterSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes