public function ResourceRoutes::onDynamicRouteEvent in Drupal 10
Same name and namespace in other branches
- 8 core/modules/rest/src/Routing/ResourceRoutes.php \Drupal\rest\Routing\ResourceRoutes::onDynamicRouteEvent()
- 9 core/modules/rest/src/Routing/ResourceRoutes.php \Drupal\rest\Routing\ResourceRoutes::onDynamicRouteEvent()
Alters existing routes for a specific collection.
Parameters
\Drupal\Core\Routing\RouteBuildEvent $event: The route build event.
Return value
array
File
- core/
modules/ rest/ src/ Routing/ ResourceRoutes.php, line 64
Class
- ResourceRoutes
- Subscriber for REST-style routes.
Namespace
Drupal\rest\RoutingCode
public function onDynamicRouteEvent(RouteBuildEvent $event) {
// Iterate over all enabled REST resource config entities.
/** @var \Drupal\rest\RestResourceConfigInterface[] $resource_configs */
$resource_configs = $this->resourceConfigStorage
->loadMultiple();
foreach ($resource_configs as $resource_config) {
if ($resource_config
->status()) {
$resource_routes = $this
->getRoutesForResourceConfig($resource_config);
$event
->getRouteCollection()
->addCollection($resource_routes);
}
}
}