RouterInterface
in
Adapter-local routing contract, the WordPress counterpart of the Moodle adapter's `RouterInterface`.
Wraps a Symfony RouteCollection and delegates attribute discovery to
the framework's RouteLoaderInterface (#[Route] reflection scan) so
controllers declare their own routes instead of a central array.
Table of Contents
Methods
- generateUrl() : string
- Generate a URL path for a named route.
- getContext() : RequestContext|null
- Get the current routing context (host, scheme, base path).
- getRoutes() : RouteCollection
- Retrieve the registered route collection.
- initializeContext() : void
- Initialize the routing context (base URL, host, scheme) from globals.
- register() : void
- Manually register a route.
- registerDefaultRoutes() : void
- Register default system routes (e.g. 404) and global regex requirements.
- scanAnnotations() : void
- Scan a controller class for `#[Route]` attributes and register the discovered routes (delegated to the framework route loader).
Methods
generateUrl()
Generate a URL path for a named route.
public
generateUrl(string $route[, array<string, mixed> $parameters = [] ][, int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH ]) : string
Parameters
- $route : string
- $parameters : array<string, mixed> = []
- $referenceType : int = UrlGeneratorInterface::ABSOLUTE_PATH
Return values
stringgetContext()
Get the current routing context (host, scheme, base path).
public
getContext() : RequestContext|null
Return values
RequestContext|nullgetRoutes()
Retrieve the registered route collection.
public
getRoutes() : RouteCollection
Return values
RouteCollectioninitializeContext()
Initialize the routing context (base URL, host, scheme) from globals.
public
initializeContext() : void
register()
Manually register a route.
public
register(string $name, string $path, string $controller, string $method[, array<string, string> $requirements = [] ]) : void
Parameters
- $name : string
- $path : string
- $controller : string
- $method : string
- $requirements : array<string, string> = []
-
regex requirements for parameters
registerDefaultRoutes()
Register default system routes (e.g. 404) and global regex requirements.
public
registerDefaultRoutes() : void
scanAnnotations()
Scan a controller class for `#[Route]` attributes and register the discovered routes (delegated to the framework route loader).
public
scanAnnotations(ContainerInterface $container[, string|null $specificClass = null ]) : void
Parameters
- $container : ContainerInterface
- $specificClass : string|null = null