You are here

public function Routes::routes in JSON:API 8

Same name and namespace in other branches
  1. 8.2 src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::routes()
1 string reference to 'Routes::routes'
jsonapi.routing.yml in ./jsonapi.routing.yml
jsonapi.routing.yml

File

src/Routing/Routes.php, line 98

Class

Routes
Defines dynamic routes.

Namespace

Drupal\jsonapi\Routing

Code

public function routes() {
  $routes = new RouteCollection();

  // JSON API's routes: entry point + routes for every resource type.
  foreach ($this->resourceTypeRepository
    ->all() as $resource_type) {
    $routes
      ->addCollection(static::getRoutesForResourceType($resource_type, $this->jsonApiBasePath));
  }
  $routes
    ->add('jsonapi.resource_list', static::getEntryPointRoute($this->jsonApiBasePath));

  // Enable all available authentication providers.
  $routes
    ->addOptions([
    '_auth' => $this->providerIds,
  ]);

  // Flag every route as belonging to the JSON API module.
  $routes
    ->addDefaults([
    static::JSON_API_ROUTE_FLAG_KEY => TRUE,
  ]);
  return $routes;
}