MIDDAG for Moodle

middag_interface

Central contract for the Middag entrypoint singleton.

Exposes kernel lifecycle operations, routing helpers, and service locator access for legacy contexts that cannot rely on constructor injection.

Table of Contents

Methods

get()  : object|T
Retrieve a service from the DI container.
get_instance()  : self
Singleton Accessor (Factory Method).
handle()  : void
Handle the current HTTP request and dispatch it to the appropriate controller.
init()  : void
Initialize the application kernel.
is_development()  : bool
Check if running in development environment.
is_production()  : bool
Check if running in production environment.
is_testing()  : bool
Check if running in PHPUnit test environment.
register_route()  : void
Register a new route manually.
register_routes_from_annotations()  : void
Register routes from PHP 8 Attributes (#[Route]) in a class.
routing()  : router_interface
Access the Route Manager directly.
shutdown()  : void
Shutdown the kernel and reset the singleton.
url_generator()  : moodle_url
Generate a Moodle URL from a Symfony route name and parameters.
webhook_url_generator()  : moodle_url
Generate a webhook URL (helper for callbacks).

Methods

get()

Retrieve a service from the DI container.

public static get(T>|string $id) : object|T
Parameters
$id : T>|string

Service ID or Class Name

Return values
object|T

get_instance()

Singleton Accessor (Factory Method).

public static get_instance() : self

Used by the Container to register 'middag' as a service.

Return values
self

handle()

Handle the current HTTP request and dispatch it to the appropriate controller.

public static handle() : void

init()

Initialize the application kernel.

public static init() : void

Idempotent: safe to call multiple times.

is_development()

Check if running in development environment.

public static is_development() : bool
Return values
bool

is_production()

Check if running in production environment.

public static is_production() : bool
Return values
bool

is_testing()

Check if running in PHPUnit test environment.

public static is_testing() : bool
Return values
bool

register_route()

Register a new route manually.

public static register_route(string $name, string $path, string $controller_class, string $method[, array<string|int, mixed> $requirements = [] ]) : void
Parameters
$name : string

Route name (e.g., 'my_route').

$path : string

URL path (e.g., '/my/path/{id}').

$controller_class : string

FQCN of the controller

$method : string

method name

$requirements : array<string|int, mixed> = []

regex requirements for parameters

register_routes_from_annotations()

Register routes from PHP 8 Attributes (#[Route]) in a class.

public static register_routes_from_annotations(string $class_name) : void

Must be called BEFORE the container is compiled.

Parameters
$class_name : string

the class to scan

routing()

Access the Route Manager directly.

public static routing() : router_interface
Return values
router_interface

shutdown()

Shutdown the kernel and reset the singleton.

public static shutdown() : void

Useful for testing isolation.

url_generator()

Generate a Moodle URL from a Symfony route name and parameters.

public static url_generator(string $route[, array<string|int, mixed> $parameters = [] ][, int $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH ]) : moodle_url
Parameters
$route : string

The route name

$parameters : array<string|int, mixed> = []

Route parameters

$reference_type : int = UrlGeneratorInterface::ABSOLUTE_PATH

URL generation type (Absolute/Relative)

Return values
moodle_url

webhook_url_generator()

Generate a webhook URL (helper for callbacks).

public static webhook_url_generator(string $route[, array<string|int, mixed> $parameters = [] ][, int $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH ]) : moodle_url
Parameters
$route : string
$parameters : array<string|int, mixed> = []
$reference_type : int = UrlGeneratorInterface::ABSOLUTE_PATH
Return values
moodle_url

        
On this page

Search results