Maintenance
Dispatcher listener that redirects traffic while maintenance mode is enabled.
The listener reads app.maintenance and router.maintenance from config and forwards matching requests before the target controller/action runs.
- Full name:
\PhalconKit\Mvc\Dispatcher\Maintenance - Parent class:
\PhalconKit\Di\Injectable
Constants
| Constant | Visibility | Type | Value |
|---|---|---|---|
DEFAULT_MAINTENANCE_MODULE | public | ?string | null |
DEFAULT_MAINTENANCE_CONTROLLER | public | ?string | 'error' |
DEFAULT_MAINTENANCE_ACTION | public | ?string | 'maintenance' |
Methods
beforeDispatch
Executed before dispatching a request.
public beforeDispatch(\Phalcon\Events\Event $event, \Phalcon\Dispatcher\AbstractDispatcher $dispatcher): void
The plugin reads app.maintenance and router.maintenance from the PhalconKit config service. When maintenance mode is enabled it forwards the dispatcher to the configured maintenance route, strips null route parts through the PhalconKit dispatcher extension when available, and stops cancelable dispatch events only while rerouting. The effective maintenance target proceeds normally, including subsequent listeners. Empty namespace/handler/action names resolve to dispatcher defaults; omitted and null parts retain the dispatcher's forwarding semantics.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$event | \Phalcon\Events\Event | The event object. |
$dispatcher | \Phalcon\Dispatcher\AbstractDispatcher | The dispatcher object. |
Throws:
If an error happened during the dispatch forwarding to the maintenance route. - Exception When the DI container or config service cannot be resolved through the PhalconKit DI contract. - ServiceException
canForwardNative
Compatibility check for native dispatchers without Core's canForward().
private canForwardNative(\Phalcon\Dispatcher\AbstractDispatcher $dispatcher, array<string,mixed> $route): bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
$dispatcher | \Phalcon\Dispatcher\AbstractDispatcher | |
$route | array | Configured route, including null parts. |