public function Routes::routes in Schemata 8
The route generator.
1 string reference to 'Routes::routes'
File
- src/
Routing/ Routes.php, line 69
Class
- Routes
- Class Routes.
Namespace
Drupal\schemata\RoutingCode
public function routes() {
$route_collection = new RouteCollection();
// Loop through all the entity types.
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type) {
$entity_type_id = $entity_type
->id();
// Add a route for all entity types.
$route_collection
->add($this
->createRouteName($entity_type_id), $this
->createRoute($entity_type_id));
// If this entity type has a bundle entity type,
// then add a route for each bundle.
if ($entity_type
->getBundleEntityType()) {
// Loop through all the bundles for the entity type.
$bundles_info = $this->entityTypeBundleInfo
->getBundleInfo($entity_type_id);
foreach (array_keys($bundles_info) as $bundle) {
$route_collection
->add($this
->createRouteName($entity_type_id, $bundle), $this
->createRoute($entity_type_id, $bundle));
}
}
}
return $route_collection;
}