ResourceRoutes::alterRoutes

protected ResourceRoutes::alterRoutes(RouteCollection $collection)

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Return value

array

Overrides RouteSubscriberBase::alterRoutes

File

core/modules/rest/src/Routing/ResourceRoutes.php, line 61

Class

ResourceRoutes
Subscriber for REST-style routes.

Namespace

Drupal\rest\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  // Iterate over all enabled REST resource configs.
  /** @var \Drupal\rest\RestResourceConfigInterface[] $resource_configs */
  $resource_configs = $this->resourceConfigStorage->loadMultiple();
  // Iterate over all enabled resource plugins.
  foreach ($resource_configs as $resource_config) {
    $resource_routes = $this->getRoutesForResourceConfig($resource_config);
    $collection->addCollection($resource_routes);
  }
}
doc_Drupal
2016-10-29 09:37:52
Comments
Leave a Comment

Please login to continue.