interface 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.

Methods

static void
init()

Initialize the application kernel.

static void
shutdown()

Shutdown the kernel and reset the singleton.

static void
handle()

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

static object
get(string $id)

Retrieve a service from the DI container.

routing()

Access the Route Manager directly.

get_instance()

Singleton Accessor (Factory Method).

static bool
is_testing()

Check if running in PHPUnit test environment.

static bool
is_development()

Check if running in development environment.

static bool
is_production()

Check if running in production environment.

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

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

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

Generate a webhook URL (helper for callbacks).

static void
register_route(string $name, string $path, string $controller_class, string $method, array $requirements = [])

Register a new route manually.

static void
register_routes_from_annotations(string $class_name)

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

Details

at line 34
static void init()

Initialize the application kernel.

Idempotent: safe to call multiple times.

Return Value

void

at line 40
static void shutdown()

Shutdown the kernel and reset the singleton.

Useful for testing isolation.

Return Value

void

at line 45
static void handle()

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

Return Value

void

at line 56
static object get(string $id)

Retrieve a service from the DI container.

Parameters

string $id

Service ID or Class Name

Return Value

object

at line 61
static router_interface routing()

Access the Route Manager directly.

Return Value

router_interface

at line 67
static middag_interface get_instance()

Singleton Accessor (Factory Method).

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

Return Value

middag_interface

at line 72
static bool is_testing()

Check if running in PHPUnit test environment.

Return Value

bool

at line 77
static bool is_development()

Check if running in development environment.

Return Value

bool

at line 82
static bool is_production()

Check if running in production environment.

Return Value

bool

at line 93
static moodle_url url_generator(string $route, array $parameters = [], int $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)

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

Parameters

string $route

The route name

array $parameters

Route parameters

int $reference_type

URL generation type (Absolute/Relative)

Return Value

moodle_url

at line 108
static moodle_url webhook_url_generator(string $route, array $parameters = [], int $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)

Generate a webhook URL (helper for callbacks).

Parameters

string $route
array $parameters
int $reference_type

Return Value

moodle_url

at line 123
static void register_route(string $name, string $path, string $controller_class, string $method, array $requirements = [])

Register a new route manually.

Parameters

string $name

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

string $path

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

string $controller_class

FQCN of the controller

string $method

method name

array $requirements

regex requirements for parameters

Return Value

void

at line 138
static void register_routes_from_annotations(string $class_name)

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

Must be called BEFORE the container is compiled.

Parameters

string $class_name

the class to scan

Return Value

void