Phalcon dispatcher
NOTE
All classes are prefixed with Phalcon
Dispatcher\AbstractDispatcher¶
Abstract Source on GitHub
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.
stdClassPhalcon\Di\AbstractInjectionAwarePhalcon\Dispatcher\AbstractDispatcher— implementsPhalcon\Dispatcher\DispatcherInterface,Phalcon\Events\EventsAwareInterface
Uses Exception · Phalcon\Di\AbstractInjectionAware · Phalcon\Di\DiInterface · Phalcon\Dispatcher\Exception · Phalcon\Dispatcher\Exceptions\ForwardInInitializeForbidden · Phalcon\Events\EventsAwareInterface · Phalcon\Events\ManagerInterface · Phalcon\Filter\FilterInterface · Phalcon\Mvc\Model\Binder · Phalcon\Mvc\Model\BinderInterface · Phalcon\Support\Collection
Method Summary¶
public callActionMethod(mixed $handler,string $actionMethod,array $params = []) public mixed|bool dispatch() Process the results of the router by calling into the appropriate public void forward( array $forward ) Forwards the execution flow to another controller/action. public string getActionName() Gets the latest dispatched action name public string getActionSuffix() Gets the default action suffix public string getActiveMethod() Returns the current method to be/executed in the dispatcher public array getBoundModels() Returns bound models from binder instance public string getDefaultNamespace() Returns the default namespace public ManagerInterface|null getEventsManager() Returns the internal event manager public string getHandlerClass() Possible class name that will be located to dispatch the request public string getHandlerSuffix() Gets the default handler suffix public BinderInterface|null getModelBinder() Gets model binder public string|null getModuleName() Gets the module where the controller class is public string getNamespaceName() Gets a namespace to be prepended to the current handler name public mixed getParam(mixed $param,mixed $filters = null,mixed $defaultValue = null) Gets a param by its name or numeric index public mixed getParameter(mixed $param,mixed $filters = null,mixed $defaultValue = null) Gets a param by its name or numeric index public array getParameters() Gets action params public array getParams() Gets action params public mixed getReturnedValue() Returns value returned by the latest dispatched action public bool hasParam( mixed $param ) Check if a param exists public bool hasParameter( mixed $param ) Check if a param exists public bool isFinished() Checks if the dispatch loop is finished or has more pendent public void setActionName( string $actionName ) Sets the action name to be dispatched public void setActionSuffix( string $actionSuffix ) Sets the default action suffix public void setDefaultAction( string $actionName ) Sets the default action name public void setDefaultNamespace( string $defaultNamespace ) Sets the default namespace public void setEventsManager( ManagerInterface $eventsManager ) Sets the events manager public void setHandlerSuffix( string $handlerSuffix ) Sets the default suffix for the handler public DispatcherInterface setModelBinder(BinderInterface $modelBinder,mixed $cache = null) Enable model binding during dispatch public void setModuleName( string $moduleName = null ) Sets the module where the controller is (only informative) public void setNamespaceName( string $namespaceName ) Sets the namespace where the controller class is public void setParam(mixed $param,mixed $value) Set a param by its name or numeric index public void setParameter(mixed $param,mixed $value) Set a param by its name or numeric index public void setParameters( array $params ) Sets action params to be dispatched public void setParams( array $params ) Sets action params to be dispatched public void setReturnedValue( mixed $value ) Sets the latest returned value by an action manually public bool wasForwarded() Check if the current executed action was forwarded by another one protected void resolveEmptyProperties() Set empty properties to their defaults (where defaults are available) protected string toCamelCase( string $input ) Properties¶
protected string $actionName = "" protected string $actionSuffix = "Action" protected object|null $activeHandler = null protected array $activeMethodMap = [] protected array $camelCaseMap = [] protected string $defaultAction = "" protected string $defaultHandler = "" protected string $defaultNamespace = "" protected ManagerInterface|null $eventsManager = null protected bool $finished = false protected bool $forwarded = false protected array $handlerHashes = [] protected array $handlerHookCache = [] protected string $handlerName = "" protected string $handlerSuffix = "" protected bool $isControllerInitialize = false protected mixed|null $lastHandler = null protected BinderInterface|null $modelBinder = null protected bool $modelBinding = false protected string $moduleName = "" protected string $namespaceName = "" protected array $params = [] protected string|null $previousActionName = "" protected string|null $previousHandlerName = "" protected string|null $previousNamespaceName = "" protected string|null $returnedValue = null Methods¶
callActionMethod()¶
dispatch()¶
Process the results of the router by calling into the appropriate controller action(s) including any routing data or injected parameters.
forward()¶
Forwards the execution flow to another controller/action.
getActionName()¶
Gets the latest dispatched action name
getActionSuffix()¶
Gets the default action suffix
getActiveMethod()¶
Returns the current method to be/executed in the dispatcher
getBoundModels()¶
Returns bound models from binder instance
class UserController extends Controller
{
public function showAction(User $user)
{
// return array with $user
$boundModels = $this->dispatcher->getBoundModels();
}
}
getDefaultNamespace()¶
Returns the default namespace
getEventsManager()¶
Returns the internal event manager
getHandlerClass()¶
Possible class name that will be located to dispatch the request
getHandlerSuffix()¶
Gets the default handler suffix
getModelBinder()¶
Gets model binder
getModuleName()¶
Gets the module where the controller class is
getNamespaceName()¶
Gets a namespace to be prepended to the current handler name
getParam()¶
Gets a param by its name or numeric index
@todo remove this in future versions
getParameter()¶
public function getParameter(
mixed $param,
mixed $filters = null,
mixed $defaultValue = null
): mixed;
Gets a param by its name or numeric index
getParameters()¶
Gets action params
getParams()¶
Gets action params
@todo remove this in future versions
getReturnedValue()¶
Returns value returned by the latest dispatched action
hasParam()¶
Check if a param exists @todo deprecate this in the future
hasParameter()¶
Check if a param exists
isFinished()¶
Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch
setActionName()¶
Sets the action name to be dispatched
setActionSuffix()¶
Sets the default action suffix
setDefaultAction()¶
Sets the default action name
setDefaultNamespace()¶
Sets the default namespace
setEventsManager()¶
Sets the events manager
setHandlerSuffix()¶
Sets the default suffix for the handler
setModelBinder()¶
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;
}
);
setModuleName()¶
Sets the module where the controller is (only informative)
setNamespaceName()¶
Sets the namespace where the controller class is
setParam()¶
Set a param by its name or numeric index @todo deprecate this in the future
setParameter()¶
Set a param by its name or numeric index
setParameters()¶
Sets action params to be dispatched
setParams()¶
Sets action params to be dispatched @todo deprecate this in the future
setReturnedValue()¶
Sets the latest returned value by an action manually
wasForwarded()¶
Check if the current executed action was forwarded by another one
resolveEmptyProperties()¶
Set empty properties to their defaults (where defaults are available)
toCamelCase()¶
Dispatcher\DispatcherInterface¶
Interface Source on GitHub
Interface for Phalcon\Dispatcher\AbstractDispatcher
Phalcon\Dispatcher\DispatcherInterface
Method Summary¶
public mixed|bool dispatch() Dispatches a handle action taking into account the routing parameters public void forward( array $forward ) Forwards the execution flow to another controller/action public string getActionName() Gets last dispatched action name public string getActionSuffix() Gets the default action suffix public string getHandlerSuffix() Gets the default handler suffix public mixed getParam(mixed $param,mixed $filters = null) Gets a param by its name or numeric index public mixed getParameter(mixed $param,mixed $filters = null) Gets a param by its name or numeric index public array getParameters() Gets action params public array getParams() Gets action params public mixed getReturnedValue() Returns value returned by the latest dispatched action public bool hasParam( mixed $param ) Check if a param exists public bool isFinished() Checks if the dispatch loop is finished or has more pendent public void setActionName( string $actionName ) Sets the action name to be dispatched public void setActionSuffix( string $actionSuffix ) Sets the default action suffix public void setDefaultAction( string $actionName ) Sets the default action name public void setDefaultNamespace( string $defaultNamespace ) Sets the default namespace public void setHandlerSuffix( string $handlerSuffix ) Sets the default suffix for the handler public void setModuleName( string $moduleName = null ) Sets the module name which the application belongs to public void setNamespaceName( string $namespaceName ) Sets the namespace which the controller belongs to public void setParam(mixed $param,mixed $value) Set a param by its name or numeric index public void setParams( array $params ) Sets action params to be dispatched Methods¶
dispatch()¶
Dispatches a handle action taking into account the routing parameters
forward()¶
Forwards the execution flow to another controller/action
getActionName()¶
Gets last dispatched action name
getActionSuffix()¶
Gets the default action suffix
getHandlerSuffix()¶
Gets the default handler suffix
getParam()¶
Gets a param by its name or numeric index
getParameter()¶
Gets a param by its name or numeric index
getParameters()¶
Gets action params
getParams()¶
Gets action params
getReturnedValue()¶
Returns value returned by the latest dispatched action
hasParam()¶
Check if a param exists
isFinished()¶
Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch
setActionName()¶
Sets the action name to be dispatched
setActionSuffix()¶
Sets the default action suffix
setDefaultAction()¶
Sets the default action name
setDefaultNamespace()¶
Sets the default namespace
setHandlerSuffix()¶
Sets the default suffix for the handler
setModuleName()¶
Sets the module name which the application belongs to
setNamespaceName()¶
Sets the namespace which the controller belongs to
setParam()¶
Set a param by its name or numeric index
setParams()¶
Sets action params to be dispatched
Dispatcher\Exception¶
Class Source on GitHub
Exceptions thrown in Phalcon\Dispatcher/* will use this class
\ExceptionPhalcon\Dispatcher\Exception
Constants¶
int EXCEPTION_ACTION_NOT_FOUND = 5 int EXCEPTION_CYCLIC_ROUTING = 1 int EXCEPTION_HANDLER_NOT_FOUND = 2 int EXCEPTION_INVALID_HANDLER = 3 int EXCEPTION_INVALID_PARAMS = 4 int EXCEPTION_NO_DI = 0 Dispatcher\Exceptions\ForwardInInitializeForbidden¶
Class Source on GitHub
This file is part of the Phalcon Framework.
(c) Phalcon Team team@phalcon.io
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Dispatcher\ExceptionPhalcon\Dispatcher\Exceptions\ForwardInInitializeForbidden
Uses Phalcon\Dispatcher\Exception