protected function RouteSubscriber::alterRoutes in Workflow 8
Alters existing routes for a specific collection.
Parameters
\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.
Overrides RouteSubscriberBase::alterRoutes
File
- src/
Routing/ RouteSubscriber.php, line 38
Class
- RouteSubscriber
- Subscriber for Workflow routes.
Namespace
Drupal\workflow\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
$field_list = workflow_get_workflow_fields_by_entity_type();
foreach ($field_list as $entityTypeId => $fields) {
/*
* @todo For entities with multiple workflow fields, Create an
* Entity workflow field list page and a route
* that redirect to the correct page.
* @todo Routes for multiple workflow fields on 3 different bundles of 1 entity type.
*/
// Generate route for default field. Redirect to workflow/{field_name}.
$path = "/{$entityTypeId}/{{$entityTypeId}}/workflow";
$route = $this
->getEntityLoadRoute($entityTypeId, $path);
$collection
->add("entity.{$entityTypeId}.workflow_history", $route);
// Generate one route for each workflow field.
foreach ($fields as $field_name => $field) {
$path = "/{$entityTypeId}/{{$entityTypeId}}/workflow/{$field_name}";
$route = $this
->getEntityLoadRoute($entityTypeId, $path);
$collection
->add("entity.{$entityTypeId}.workflow_history.{$field_name}", $route);
}
}
}