Dispatcher
WebSocket task dispatcher.
WebSocket requests use CLI-style task dispatching, with the shared PhalconKit dispatcher helpers layered on top for namespace/action handling.
- Full name:
\PhalconKit\Ws\Dispatcher - Parent class:
\PhalconKit\Cli\Dispatcher - This class implements:
\PhalconKit\Ws\DispatcherInterface
Inherited methods
getNamespaceName
Return the namespace currently targeted by the dispatcher.
public getNamespaceName(): ?string
- This method is abstract.
getModuleName
Return the module currently targeted by the dispatcher.
public getModuleName(): ?string
- This method is abstract.
setModuleName
Update the current module name before forwarding.
public setModuleName(?string $moduleName = null): void
- This method is abstract. Parameters:
| Parameter | Type | Description |
|---|---|---|
$moduleName | ?string |
getActionName
Return the action currently targeted by the dispatcher.
public getActionName(): string
- This method is abstract.
getParameters
Return current dispatch parameters.
public getParameters(): array<int|string,mixed>
- This method is abstract.
getHandlerClass
Return the resolved controller or task class name.
public getHandlerClass(): string
- This method is abstract.
getHandlerSuffix
Return the native handler suffix used by the dispatcher.
public getHandlerSuffix(): string
- This method is abstract.
getActionSuffix
Return the native action suffix used by the dispatcher.
public getActionSuffix(): string
- This method is abstract.
getActiveMethod
Return the concrete handler method name Phalcon will invoke.
public getActiveMethod(): string
- This method is abstract.
callActionMethod
Invoke a controller or task action with positional parameters only.
public callActionMethod(mixed $handler, string $actionMethod, array<int|string,mixed> $params = []): mixed
Phalcon stores dispatch params as an array that may contain named metadata. Only integer-keyed entries are passed to action method arguments so route metadata cannot accidentally shift the method signature.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$handler | mixed | Controller or task instance selected by Phalcon. |
$actionMethod | string | Method name to call on the handler. |
$params | array | Dispatch parameters. |
Return Value:
Action return value.
forward
Forward to another target, optionally skipping cyclic forwards.
public forward(array<string,mixed> $forward, bool $preventCycle = false): void
Null forward parts are stripped before delegating to Phalcon. When $preventCycle is true, forwarding only happens if at least one target part differs from the effective current dispatch state. Empty namespace, handler and action names resolve to Phalcon's configured defaults.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$forward | array | Forward target parts. |
$preventCycle | bool | Whether identical forwards should be ignored. |
canForward
Determine whether a forward changes the effective dispatch target.
public canForward(array<array-key,mixed> $forward): bool
Empty namespace, handler and action names use Phalcon's defaults on both sides of the comparison. Null and omitted parts leave the current route unchanged; module and parameter values are compared strictly. Native forward() accepts controller and task keys in either mode, with controller taking precedence. This check does not mutate dispatch state or fire events, so listeners can safely decide whether to cancel a pass.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$forward | array | Forward target parts. |
canForwardHandler
Compare the effective handler using native forward() key precedence.
private canForwardHandler(array<string,mixed> $forward): bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
$forward | array | Forward target parts. |
unsetForwardNullParts
Remove null parts from a forward target before delegating to Phalcon.
public unsetForwardNullParts(array<string,mixed> $forward, array<int,string>|null $parts = null): array<string,mixed>
Parameters:
| Parameter | Type | Description |
|---|---|---|
$forward | array | Forward target parts. |
$parts | array | Forward keys to inspect. Defaults |
| to the common MVC and CLI target keys. |
Return Value:
Forward target with null parts removed.
toArray
Export the active dispatcher state for diagnostics and debug responses.
public toArray(): array<string,mixed>
Return Value:
Current namespace, module, handler, action, parameters, and dispatcher-specific previous route state.