public function Routes::routes in Drupal 10
Same name and namespace in other branches
- 8 core/modules/jsonapi/src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::routes()
- 9 core/modules/jsonapi/src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::routes()
1 string reference to 'Routes::routes'
- jsonapi.routing.yml in core/modules/jsonapi/jsonapi.routing.yml
- core/modules/jsonapi/jsonapi.routing.yml
File
- core/modules/jsonapi/src/Routing/Routes.php, line 110
Class
- Routes
- Defines dynamic routes.
Namespace
Drupal\jsonapi\Routing
Code
public function routes() {
$routes = new RouteCollection();
$upload_routes = new RouteCollection();
foreach ($this->resourceTypeRepository
->all() as $resource_type) {
$routes
->addCollection(static::getRoutesForResourceType($resource_type, $this->jsonApiBasePath));
$upload_routes
->addCollection(static::getFileUploadRoutesForResourceType($resource_type, $this->jsonApiBasePath));
}
$routes
->add('jsonapi.resource_list', static::getEntryPointRoute($this->jsonApiBasePath));
$routes
->addRequirements([
'_content_type_format' => 'api_json',
]);
$upload_routes
->addRequirements([
'_content_type_format' => 'bin',
]);
$routes
->addCollection($upload_routes);
$routes
->addOptions([
'_auth' => $this->providerIds,
]);
$routes
->addDefaults([
static::JSON_API_ROUTE_FLAG_KEY => TRUE,
]);
$routes
->addRequirements([
'_format' => 'api_json',
]);
return $routes;
}