function Routes::__construct

Same name in other branches
  1. 9 core/modules/jsonapi/src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::__construct()
  2. 8.9.x core/modules/jsonapi/src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::__construct()
  3. 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(!str_ends_with($jsonapi_base_path, '/'), sprintf('The provided base path should not contain a trailing slash "/". Given: "%s".', $jsonapi_base_path));
    $this->jsonApiBasePath = $jsonapi_base_path;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.