KernelMiddleware
extends AbstractMiddleware
in package
Table of Contents
- $kernelConfig : KernelConfig
- $pathError : mixed
- __construct() : mixed
- Constructor to inject the response factory.
- process() : ResponseInterface
- Process an incoming server request.
- inMaintenanceMode() : bool
- Checks for maintenance mode across different scopes and terminates execution if enabled.
- isValidInstallerPath() : bool
- log() : LoggerInterface
- multiMerge() : array<string|int, mixed>
- Merges two multi-dimensional arrays recursively.
- when() : void
- getMaintenanceMessage() : string
- Get the maintenance message.
Properties
$kernelConfig
private
KernelConfig
$kernelConfig
$pathError
private
mixed
$pathError
Methods
__construct()
Constructor to inject the response factory.
public
__construct(KernelConfig $kernelConfig) : mixed
Parameters
- $kernelConfig : KernelConfig
Return values
mixed —process()
Process an incoming server request.
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface
Return values
ResponseInterface —inMaintenanceMode()
Checks for maintenance mode across different scopes and terminates execution if enabled.
protected
inMaintenanceMode() : bool
This function checks for a .maintenance file in various locations, affecting different scopes of the application:
- The entire tenant network (when located in PUBLIC_WEB_DIR or APP_PATH/configs_dir).
- A single tenant (when located in the current application path). If a .maintenance file is found, it terminates the execution with a maintenance message and sends a 503 Service Unavailable status code.
Return values
bool —isValidInstallerPath()
protected
isValidInstallerPath(bool $isProd) : bool
Parameters
- $isProd : bool
Return values
bool —log()
protected
log() : LoggerInterface
Return values
LoggerInterface —multiMerge()
Merges two multi-dimensional arrays recursively.
protected
static multiMerge(array<string|int, mixed> $array1, array<string|int, mixed> $array2) : array<string|int, mixed>
This function will recursively merge the values of $array2
into $array1
.
If the same key exists in both arrays, and both corresponding values are arrays,
the values are recursively merged.
Otherwise, values from $array2
will overwrite those in $array1
.
Parameters
- $array1 : array<string|int, mixed>
-
The base array that will be merged into.
- $array2 : array<string|int, mixed>
-
The array with values to merge into
$array1
.
Return values
array<string|int, mixed> —The merged array.
when()
protected
when() : void
Return values
void —getMaintenanceMessage()
Get the maintenance message.
private
static getMaintenanceMessage() : string
This method returns a predefined maintenance message indicating that the server is temporarily unavailable due to maintenance. It's used to inform users about the temporary unavailability of the service.