You are here

public function Routes::__construct in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::__construct()
  2. 10 core/modules/jsonapi/src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::__construct()

Instantiates a Routes object.

Parameters

\Drupal\jsonapi\ResourceType\ResourceTypeRepositoryInterface $resource_type_repository: The JSON:API resource type repository.

string[] $authentication_providers: The authentication providers, keyed by ID.

string $jsonapi_base_path: The JSON:API base path.

File

core/modules/jsonapi/src/Routing/Routes.php, line 81

Class

Routes
Defines dynamic routes.

Namespace

Drupal\jsonapi\Routing

Code

public function __construct(ResourceTypeRepositoryInterface $resource_type_repository, array $authentication_providers, $jsonapi_base_path) {
  $this->resourceTypeRepository = $resource_type_repository;
  $this->providerIds = array_keys($authentication_providers);
  assert(is_string($jsonapi_base_path));
  assert($jsonapi_base_path[0] === '/', sprintf('The provided base path should contain a leading slash "/". Given: "%s".', $jsonapi_base_path));
  assert(substr($jsonapi_base_path, -1) !== '/', sprintf('The provided base path should not contain a trailing slash "/". Given: "%s".', $jsonapi_base_path));
  $this->jsonApiBasePath = $jsonapi_base_path;
}