Dispatcher\AbstractDispatcher 
-
Namespace
Phalcon\Dispatcher
-
Uses
ExceptionPhalcon\Di\AbstractInjectionAwarePhalcon\Di\DiInterfacePhalcon\Dispatcher\ExceptionPhalcon\Events\EventsAwareInterfacePhalcon\Events\ManagerInterfacePhalcon\Filter\FilterInterfacePhalcon\Mvc\Model\BinderPhalcon\Mvc\Model\BinderInterface
-
Extends
AbstractInjectionAware -
Implements
DispatcherInterfaceEventsAwareInterface
This is the base class for Phalcon\Mvc\Dispatcher and Phalcon\Cli\Dispatcher. This class can’t be instantiated directly, you can use it to create your own dispatchers.
Properties
//
protected $activeHandler;
/**
* @var array
*/
protected $activeMethodMap;
//
protected $actionName = '';
/**
* @var string
*/
protected $actionSuffix = 'Action';
/**
* @var array
*/
protected $camelCaseMap;
/**
* @var string
*/
protected $defaultAction = '';
//
protected $defaultNamespace;
//
protected $defaultHandler;
/**
* @var array
*/
protected $handlerHashes;
//
protected $handlerName;
/**
* @var string
*/
protected $handlerSuffix = '';
/**
* @var ManagerInterface|null
*/
protected $eventsManager;
/**
* @var bool
*/
protected $finished = false;
/**
* @var bool
*/
protected $forwarded = false;
/**
* @var bool
*/
protected $isControllerInitialize = false;
//
protected $lastHandler;
//
protected $modelBinder;
/**
* @var bool
*/
protected $modelBinding = false;
/**
* @var string
*/
protected $moduleName = '';
/**
* @var string
*/
protected $namespaceName = '';
/**
* @var array
*/
protected $params;
//
protected $previousActionName = '';
//
protected $previousHandlerName = '';
//
protected $previousNamespaceName = '';
//
protected $returnedValue;Methods
public function callActionMethod( mixed $handler, string $actionMethod, array $params = [] );public function dispatch(): mixed | bool;Process the results of the router by calling into the appropriate controller action(s) including any routing data or injected parameters.
public function forward( array $forward ): void;Forwards the execution flow to another controller/action.
$this->dispatcher->forward(
[
"controller" => "posts",
"action" => "index",
]
);public function getActionName(): string;Gets the latest dispatched action name
public function getActionSuffix(): string;Gets the default action suffix
public function getActiveMethod(): string;Returns the current method to be/executed in the dispatcher
public function getBoundModels(): array;Returns bound models from binder instance
class UserController extends Controller
{
public function showAction(User $user)
{
// return array with $user
$boundModels = $this->dispatcher->getBoundModels();
}
}public function getDefaultNamespace(): string;Returns the default namespace
public function getEventsManager(): ManagerInterface;Returns the internal event manager
public function getHandlerClass(): string;Possible class name that will be located to dispatch the request
public function getHandlerSuffix(): string;Gets the default handler suffix
public function getModelBinder(): BinderInterface | null;Gets model binder
public function getModuleName(): string;Gets the module where the controller class is
public function getNamespaceName(): string;Gets a namespace to be prepended to the current handler name
public function getParam( mixed $param, mixed $filters = null, mixed $defaultValue = null ): mixed;Gets a param by its name or numeric index
public function getParams(): array;Gets action params
public function getReturnedValue(): mixed;Returns value returned by the latest dispatched action
public function hasParam( mixed $param ): bool;Check if a param exists
public function isFinished(): bool;Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch
public function setActionName( string $actionName ): void;Sets the action name to be dispatched
public function setActionSuffix( string $actionSuffix ): void;Sets the default action suffix
public function setDefaultAction( string $actionName ): void;Sets the default action name
public function setDefaultNamespace( string $namespaceName ): void;Sets the default namespace
public function setEventsManager( ManagerInterface $eventsManager ): void;Sets the events manager
public function setHandlerSuffix( string $handlerSuffix ): void;Sets the default suffix for the handler
public function setModelBinder( BinderInterface $modelBinder, mixed $cache = null ): DispatcherInterface;Enable model binding during dispatch
$di->set(
'dispatcher',
function() {
$dispatcher = new Dispatcher();
$dispatcher->setModelBinder(
new Binder(),
'cache'
);
return $dispatcher;
}
);public function setModuleName( string $moduleName ): void;Sets the module where the controller is (only informative)
public function setNamespaceName( string $namespaceName ): void;Sets the namespace where the controller class is
public function setParam( mixed $param, mixed $value ): void;Set a param by its name or numeric index
public function setParams( array $params ): void;Sets action params to be dispatched
public function setReturnedValue( mixed $value ): void;Sets the latest returned value by an action manually
public function wasForwarded(): bool;Check if the current executed action was forwarded by another one
protected function resolveEmptyProperties(): void;Set empty properties to their defaults (where defaults are available)
protected function toCamelCase( string $input ): string;Dispatcher\DispatcherInterface 
-
Namespace
Phalcon\Dispatcher
-
Uses
-
Extends
-
Implements
Interface for Phalcon\Dispatcher\AbstractDispatcher
Methods
public function dispatch(): mixed | bool;Dispatches a handle action taking into account the routing parameters
public function forward( array $forward ): void;Forwards the execution flow to another controller/action
public function getActionName(): string;Gets last dispatched action name
public function getActionSuffix(): string;Gets the default action suffix
public function getHandlerSuffix(): string;Gets the default handler suffix
public function getParam( mixed $param, mixed $filters = null ): mixed;Gets a param by its name or numeric index
public function getParams(): array;Gets action params
public function getReturnedValue(): mixed;Returns value returned by the latest dispatched action
public function hasParam( mixed $param ): bool;Check if a param exists
public function isFinished(): bool;Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch
public function setActionName( string $actionName ): void;Sets the action name to be dispatched
public function setActionSuffix( string $actionSuffix ): void;Sets the default action suffix
public function setDefaultAction( string $actionName ): void;Sets the default action name
public function setDefaultNamespace( string $defaultNamespace ): void;Sets the default namespace
public function setHandlerSuffix( string $handlerSuffix ): void;Sets the default suffix for the handler
public function setModuleName( string $moduleName ): void;Sets the module name which the application belongs to
public function setNamespaceName( string $namespaceName ): void;Sets the namespace which the controller belongs to
public function setParam( mixed $param, mixed $value ): void;Set a param by its name or numeric index
public function setParams( array $params ): void;Sets action params to be dispatched
Dispatcher\Exception
-
Namespace
Phalcon\Dispatcher
-
Uses
-
Extends
\Exception -
Implements
Exceptions thrown in Phalcon\Dispatcher/* will use this class
Constants
const EXCEPTION_ACTION_NOT_FOUND = 5;
const EXCEPTION_CYCLIC_ROUTING = 1;
const EXCEPTION_HANDLER_NOT_FOUND = 2;
const EXCEPTION_INVALID_HANDLER = 3;
const EXCEPTION_INVALID_PARAMS = 4;
const EXCEPTION_NO_DI = 0;