class router implements router_interface

internal  
 

Router.

Handles the storage, context resolution, and URL generation for routes. Delegates the discovery (loading) of routes to route_loader_interface.

Constants

private ENTRY_POINT

Methods

__construct(route_loader_interface|null $loader = new route_loader())

No description

void
initialize_context()

Initializes the Routing Context based on the current Globals.

RouteCollection
get_routes()

Retrieve the registered route collection.

RequestContext|null
get_context()

Get the current routing context (host, scheme, base path).

void
register_default_routes()

Registers default system routes (e.g. 404) and global regex patterns.

void
register(string $name, string $path, string $controller, string $method, array $requirements = [])

Manually registers a route.

void
scan_annotations(ContainerInterface $container, string|null $specific_class = null)

Delegates scanning to the Loader.

moodle_url
generate_url(string $route, array $parameters = [], int $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)

Generates a URL for a given route.

Details

at line 63
__construct(route_loader_interface|null $loader = new route_loader())

No description

Parameters

route_loader_interface|null $loader

Optional loader. Defaults to concrete route_loader.

at line 72
void initialize_context()

Initializes the Routing Context based on the current Globals.

Sets the base URL specific to this Moodle plugin.

Return Value

void

at line 87
RouteCollection get_routes()

Retrieve the registered route collection.

Return Value

RouteCollection

at line 97
RequestContext|null get_context()

Get the current routing context (host, scheme, base path).

Return Value

RequestContext|null

at line 105
void register_default_routes()

Registers default system routes (e.g. 404) and global regex patterns.

Return Value

void

at line 130
void register(string $name, string $path, string $controller, string $method, array $requirements = [])

Manually registers a route.

Parameters

string $name

Unique route name

string $path

Route path

string $controller

FQCN of controller

string $method

Controller method

array $requirements

Parameter regex requirements

Return Value

void

at line 143
void scan_annotations(ContainerInterface $container, string|null $specific_class = null)

Delegates scanning to the Loader.

Parameters

ContainerInterface $container

DI container with controllers

string|null $specific_class

Optional FQCN to limit the scan

Return Value

void

at line 164
moodle_url generate_url(string $route, array $parameters = [], int $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)

Generates a URL for a given route.

Parameters

string $route

Route identifier

array $parameters

Route parameters

int $reference_type

Symfony reference type constant

Return Value

moodle_url