final class TeamAppByNameRouteAlterSubscriber in Apigee Edge 8
Changes the 'type' of the 'team_app' route parameter if 'team' is available.
The {team_app} parameter has already automatically resolved by EntityResolverManager and it is expected to contain a Team app id (UUID) because this is what entity load can accept. Although, we wanted to generate more user friendly paths for Team apps that does not yet have a _separated_ "Team apps" page, similar to "Apps" page for developer apps. Therefore we added the team id (team name) to some regular team app entity routes (ex.: canonical, add/edit/delete-form, etc.) and set the {team_app} parameter's value to team app's name instead of its id (UUID).
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\apigee_edge_teams\Routing\TeamAppByNameRouteAlterSubscriber
Expanded class hierarchy of TeamAppByNameRouteAlterSubscriber
See also
\Drupal\apigee_edge_teams\Entity\TeamApp::urlRouteParameters()
1 string reference to 'TeamAppByNameRouteAlterSubscriber'
- 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 TeamAppByNameRouteAlterSubscriber
File
- modules/
apigee_edge_teams/ src/ Routing/ TeamAppByNameRouteAlterSubscriber.php, line 41
Namespace
Drupal\apigee_edge_teams\RoutingView source
final class TeamAppByNameRouteAlterSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
foreach ($collection as $id => $route) {
if (strpos($id, 'entity.team_app') !== FALSE && in_array('team', $route
->compile()
->getPathVariables()) && in_array('app', $route
->compile()
->getPathVariables())) {
$params = $route
->getOption('parameters') ?? [];
NestedArray::setValue($params, [
'team',
'type',
], 'entity:team');
NestedArray::setValue($params, [
'app',
'type',
], 'team_app_by_name');
$route
->setOption('parameters', $params);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriberBase:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | 5 |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |
TeamAppByNameRouteAlterSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |