Routes
class Routes implements ContainerInjectionInterface (View source)
| internal | JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it. |
Defines dynamic routes.
Constants
| CONTROLLER_SERVICE_NAME |
The service name for the primary JSON:API controller. All resources except the entrypoint are served by this controller. |
| JSON_API_ROUTE_FLAG_KEY |
A key with which to flag a route as belonging to the JSON:API module. |
| RESOURCE_TYPE_KEY |
The route default key for the route's resource type information. |
Properties
| protected ResourceTypeRepositoryInterface | $resourceTypeRepository | The JSON:API resource type repository. |
|
| protected string[] | $providerIds | List of providers. |
|
| protected string | $jsonApiBasePath | The JSON:API base path. |
Methods
Instantiates a Routes object.
Instantiates a new instance of this class.
{@inheritdoc}
Gets applicable resource routes for a JSON:API resource type.
Gets the file upload route collection for the given resource type.
Determines if the given request is for a JSON:API generated route.
Gets a route collection for the given resource type.
Provides the entry point route.
Adds a parameter option to a route, overrides options of the same name.
Get a unique route name for the JSON:API resource type and route type.
Get a unique route name for the file upload resource type and route type.
Determines if an array of resource types has any non-internal ones.
Determines if an array of resource types lists non-internal "file" ones.
Gets the resource type from a route or request's parameters.
Invalidates any JSON:API resource type dependent responses and routes.
Details
__construct(ResourceTypeRepositoryInterface $resource_type_repository, array $authentication_providers, string $jsonapi_base_path)
Instantiates a Routes object.
static
create(ContainerInterface $container)
Instantiates a new instance of this class.
This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.
routes()
{@inheritdoc}
static protected RouteCollection
getRoutesForResourceType(ResourceType $resource_type, string $path_prefix)
Gets applicable resource routes for a JSON:API resource type.
static protected RouteCollection
getFileUploadRoutesForResourceType(ResourceType $resource_type, string $path_prefix)
Gets the file upload route collection for the given resource type.
static bool
isJsonApiRequest(array $defaults)
Determines if the given request is for a JSON:API generated route.
static protected RouteCollection
getIndividualRoutesForResourceType(ResourceType $resource_type)
Gets a route collection for the given resource type.
protected Route
getEntryPointRoute(string $path_prefix)
Provides the entry point route.
static protected
addRouteParameter(Route $route, string $name, mixed $parameter)
Adds a parameter option to a route, overrides options of the same name.
The Symfony Route class only has a method for adding options which overrides any previous values. Therefore, it is tedious to add a single parameter while keeping those that are already set.
static string
getRouteName(ResourceType $resource_type, string $route_type)
Get a unique route name for the JSON:API resource type and route type.
static protected string
getFileUploadRouteName(ResourceType $resource_type, string $route_type)
Get a unique route name for the file upload resource type and route type.
static protected bool
hasNonInternalTargetResourceTypes(array $resource_types)
Determines if an array of resource types has any non-internal ones.
static protected bool
hasNonInternalFileTargetResourceTypes(array $resource_types)
Determines if an array of resource types lists non-internal "file" ones.
static ResourceType|null
getResourceTypeNameFromParameters(array $parameters)
Gets the resource type from a route or request's parameters.
static
rebuild()
Invalidates any JSON:API resource type dependent responses and routes.