function ResourceRoutes::onDynamicRouteEvent
Same name in other branches
- 8.9.x core/modules/rest/src/Routing/ResourceRoutes.php \Drupal\rest\Routing\ResourceRoutes::onDynamicRouteEvent()
- 10 core/modules/rest/src/Routing/ResourceRoutes.php \Drupal\rest\Routing\ResourceRoutes::onDynamicRouteEvent()
- 11.x 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);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.