kernel
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
Boot the kernel and initialize the container.
Reset the kernel state.
Sets the internal container instance manually.
Access the Booted Container.
Retrieve a service from the container (Facade/Service Locator pattern).
Runtime override of a container entry.
Dispatch the current HTTP request to the appropriate controller.
Dispatch an event or signal through the framework's event dispatcher.
Access the Router to register routes manually or inspect current routes.
Details
at line 87
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.
at line 102
static void
shutdown()
Reset the kernel state.
Essential for PHPUnit isolation to prevent state leakage between tests.
at line 124
void
set_internal_container(ContainerInterface $container)
| internal | used strictly by the ContainerFactory during the build process |
Sets the internal container instance manually.
at line 136
static ContainerInterface
container()
Access the Booted Container.
at line 162
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.
at line 192
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.
at line 207
static void
handle()
Dispatch the current HTTP request to the appropriate controller.
Delegates the heavy lifting to the HttpKernel.
at line 229
static object
dispatch(object $event)
Dispatch an event or signal through the framework's event dispatcher.
at line 249
static router_interface
routing()
Access the Router to register routes manually or inspect current routes.