class kernel implements kernel_interface

internal  
 

Application Kernel.

The central orchestrator for the plugin. It manages the lifecycle of the Dependency Injection (DI) Container, initialization of loaders, and the booting process of the modular architecture.

Architecture Note: This class implements the Singleton pattern intentionally to bridge Moodle's procedural global execution flow with the plugin's Object-Oriented Domain. It ensures the massive ContainerBuilder is compiled exactly once per request.

Constants

PROJECT_ROOT

Absolute path to the plugin source root (classes directory).

Calculates based on current file location: core/kernel/kernel.php -> classes/.

Methods

static void
init()

Boot the kernel and initialize the container.

static void
shutdown()

Reset the kernel state.

void
set_internal_container(ContainerInterface $container)

Sets the internal container instance manually.

static ContainerInterface
container()

Access the Booted Container.

static object
get(string $id)

Retrieve a service from the container (Facade/Service Locator pattern).

static void
instance(string $id, object $instance)

Runtime override of a container entry.

static void
handle()

Dispatch the current HTTP request to the appropriate controller.

routing()

Access the Router to register routes manually or inspect current routes.

Details

at line 86
static void init()

Boot the kernel and initialize the container.

This method is idempotent: calling it multiple times has no effect unless shutdown() is explicitly called.

Return Value

void

at line 101
static void shutdown()

Reset the kernel state.

Essential for PHPUnit isolation to prevent state leakage between tests.

Return Value

void

at line 123
void set_internal_container(ContainerInterface $container)

internal  used strictly by the ContainerFactory during the build process
 

Sets the internal container instance manually.

Parameters

ContainerInterface $container

Return Value

void

at line 135
static ContainerInterface container()

Access the Booted Container.

Return Value

ContainerInterface

Exceptions

RuntimeException

at line 161
static object get(string $id)

Retrieve a service from the container (Facade/Service Locator pattern).

WARNING: Prefer dependency injection (Constructor Injection) over using this method. This method is primarily for use in legacy Moodle files (lib.php, version.php), Hooks, or mustache templates contexts.

Parameters

string $id

the service identifier or class name

Return Value

object

Exceptions

RuntimeException

at line 191
static void instance(string $id, object $instance)

Runtime override of a container entry.

Allows Facades (or tests) to replace services even after the container is compiled.

Parameters

string $id

service ID

object $instance

the instance to use

Return Value

void

at line 206
static void handle()

Dispatch the current HTTP request to the appropriate controller.

Delegates the heavy lifting to the HttpKernel.

Return Value

void

Exceptions

RuntimeException

at line 226
static router_interface routing()

Access the Router to register routes manually or inspect current routes.

Return Value

router_interface