Core Service Provider - chsxf/mfx GitHub Wiki
MFX services can be accessed through the Core Service Provider, which implements the ICoreServiceProvider
interface.
Access From a Route
When a route provider extends from BaseRouteProvider
, you can access the Core Service Provider from any route implemented as an instance method.
#[Route, AnonmousRoute]
public function myRoute(array $params): RequestResult {
$sp = $this->serviceProvider;
// ...
}
Service Getters
Once you have access to the Core Service Provider, you can obtain a reference to any services through the following methods:
function getAuthenticationService(): IAuthenticationService;
function getConfigService(): IConfigService;
function getDatabaseService(): IDatabaseService;
function getLocalizationService(): ILocalizationService;
function getProfilingService(): IProfilingService;
function getRequestService(): IRequestService;
function getScriptService(): IScriptService;
function getSessionService(): ISessionService;
function getStyleSheetService(): IStyleSheetService;
function getTemplateService(): ITemplateService;
Example
#[Route, AnonmousRoute]
public function myRoute(array $params): void {
$authService = $this->serviceProvider->getAuthenticationService();
// ...
}