Dispatcher\AbstractDispatcher
AbstractSource on GitHubThis 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
publiccallActionMethod(mixed$handler,string$actionMethod,array$params = [])publicmixed|booldispatch()Process the results of the router by calling into the appropriatepublicvoidforward( array$forward )Forwards the execution flow to another controller/action.publicstringgetActionName()Gets the latest dispatched action namepublicstringgetActionSuffix()Gets the default action suffixpublicstringgetActiveMethod()Returns the current method to be/executed in the dispatcherpublicarraygetBoundModels()Returns bound models from binder instancepublicstringgetDefaultNamespace()Returns the default namespacepublicManagerInterface|nullgetEventsManager()Returns the internal event managerpublicstringgetHandlerClass()Possible class name that will be located to dispatch the requestpublicstringgetHandlerSuffix()Gets the default handler suffixpublicBinderInterface|nullgetModelBinder()Gets model binderpublicstring|nullgetModuleName()Gets the module where the controller class ispublicstringgetNamespaceName()Gets a namespace to be prepended to the current handler namepublicmixedgetParam(mixed$param,mixed$filters = null,mixed$defaultValue = null)Gets a param by its name or numeric indexpublicmixedgetParameter(mixed$param,mixed$filters = null,mixed$defaultValue = null)Gets a param by its name or numeric indexpublicarraygetParameters()Gets action paramspublicarraygetParams()Gets action paramspublicmixedgetReturnedValue()Returns value returned by the latest dispatched actionpublicboolhasParam( mixed$param )Check if a param existspublicboolhasParameter( mixed$param )Check if a param existspublicboolisFinished()Checks if the dispatch loop is finished or has more pendentpublicvoidsetActionName( string$actionName )Sets the action name to be dispatchedpublicvoidsetActionSuffix( string$actionSuffix )Sets the default action suffixpublicvoidsetDefaultAction( string$actionName )Sets the default action namepublicvoidsetDefaultNamespace( string$defaultNamespace )Sets the default namespacepublicvoidsetEventsManager( ManagerInterface$eventsManager )Sets the events managerpublicvoidsetHandlerSuffix( string$handlerSuffix )Sets the default suffix for the handlerpublicDispatcherInterfacesetModelBinder(BinderInterface$modelBinder,mixed$cache = null)Enable model binding during dispatchpublicvoidsetModuleName( string$moduleName = null )Sets the module where the controller is (only informative)publicvoidsetNamespaceName( string$namespaceName )Sets the namespace where the controller class ispublicvoidsetParam(mixed$param,mixed$value)Set a param by its name or numeric indexpublicvoidsetParameter(mixed$param,mixed$value)Set a param by its name or numeric indexpublicvoidsetParameters( array$params )Sets action params to be dispatchedpublicvoidsetParams( array$params )Sets action params to be dispatchedpublicvoidsetReturnedValue( mixed$value )Sets the latest returned value by an action manuallypublicboolwasForwarded()Check if the current executed action was forwarded by another oneprotectedvoidresolveEmptyProperties()Set empty properties to their defaults (where defaults are available)protectedstringtoCamelCase( string$input )Properties
protectedstring$actionName = ""protectedstring$actionSuffix = "Action"protectedobject|null$activeHandler = nullprotectedarray$activeMethodMap = []protectedarray$camelCaseMap = []protectedstring$defaultAction = ""protectedstring$defaultHandler = ""protectedstring$defaultNamespace = ""protectedManagerInterface|null$eventsManager = nullprotectedbool$finished = falseprotectedbool$forwarded = falseprotectedarray$handlerHashes = []protectedarray$handlerHookCache = []protectedstring$handlerName = ""protectedstring$handlerSuffix = ""protectedbool$isControllerInitialize = falseprotectedmixed|null$lastHandler = nullprotectedBinderInterface|null$modelBinder = nullprotectedbool$modelBinding = falseprotectedstring$moduleName = ""protectedstring$namespaceName = ""protectedarray$params = []protectedstring|null$previousActionName = ""protectedstring|null$previousHandlerName = ""protectedstring|null$previousNamespaceName = ""protectedstring|null$returnedValue = nullMethods
callActionMethod()
public function callActionMethod(
mixed $handler,
string $actionMethod,
array $params = []
);dispatch()
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.
forward()
public function forward( array $forward ): void;Forwards the execution flow to another controller/action.
$this->dispatcher->forward(
[
"controller" => "posts",
"action" => "index",
]
);getActionName()
public function getActionName(): string;Gets the latest dispatched action name
getActionSuffix()
public function getActionSuffix(): string;Gets the default action suffix
getActiveMethod()
public function getActiveMethod(): string;Returns the current method to be/executed in the dispatcher
getBoundModels()
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();
}
}getDefaultNamespace()
public function getDefaultNamespace(): string;Returns the default namespace
getEventsManager()
public function getEventsManager(): ManagerInterface|null;Returns the internal event manager
getHandlerClass()
public function getHandlerClass(): string;Possible class name that will be located to dispatch the request
getHandlerSuffix()
public function getHandlerSuffix(): string;Gets the default handler suffix
getModelBinder()
public function getModelBinder(): BinderInterface|null;Gets model binder
getModuleName()
public function getModuleName(): string|null;Gets the module where the controller class is
getNamespaceName()
public function getNamespaceName(): string;Gets a namespace to be prepended to the current handler name
getParam()
public function getParam(
mixed $param,
mixed $filters = null,
mixed $defaultValue = null
): mixed;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()
public function getParameters(): array;Gets action params
getParams()
public function getParams(): array;Gets action params
@todo remove this in future versions
getReturnedValue()
public function getReturnedValue(): mixed;Returns value returned by the latest dispatched action
hasParam()
public function hasParam( mixed $param ): bool;Check if a param exists @todo deprecate this in the future
hasParameter()
public function hasParameter( mixed $param ): bool;Check if a param exists
isFinished()
public function isFinished(): bool;Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch
setActionName()
public function setActionName( string $actionName ): void;Sets the action name to be dispatched
setActionSuffix()
public function setActionSuffix( string $actionSuffix ): void;Sets the default action suffix
setDefaultAction()
public function setDefaultAction( string $actionName ): void;Sets the default action name
setDefaultNamespace()
public function setDefaultNamespace( string $defaultNamespace ): void;Sets the default namespace
setEventsManager()
public function setEventsManager( ManagerInterface $eventsManager ): void;Sets the events manager
setHandlerSuffix()
public function setHandlerSuffix( string $handlerSuffix ): void;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()
public function setModuleName( string $moduleName = null ): void;Sets the module where the controller is (only informative)
setNamespaceName()
public function setNamespaceName( string $namespaceName ): void;Sets the namespace where the controller class is
setParam()
public function setParam(
mixed $param,
mixed $value
): void;Set a param by its name or numeric index @todo deprecate this in the future
setParameter()
public function setParameter(
mixed $param,
mixed $value
): void;Set a param by its name or numeric index
setParameters()
public function setParameters( array $params ): void;Sets action params to be dispatched
setParams()
public function setParams( array $params ): void;Sets action params to be dispatched @todo deprecate this in the future
setReturnedValue()
public function setReturnedValue( mixed $value ): void;Sets the latest returned value by an action manually
wasForwarded()
public function wasForwarded(): bool;Check if the current executed action was forwarded by another one
resolveEmptyProperties()
protected function resolveEmptyProperties(): void;Set empty properties to their defaults (where defaults are available)
toCamelCase()
protected function toCamelCase( string $input ): string;Dispatcher\DispatcherInterface
InterfaceSource on GitHubInterface for Phalcon\Dispatcher\AbstractDispatcher
Phalcon\Dispatcher\DispatcherInterface
Method Summary
publicmixed|booldispatch()Dispatches a handle action taking into account the routing parameterspublicvoidforward( array$forward )Forwards the execution flow to another controller/actionpublicstringgetActionName()Gets last dispatched action namepublicstringgetActionSuffix()Gets the default action suffixpublicstringgetHandlerSuffix()Gets the default handler suffixpublicmixedgetParam(mixed$param,mixed$filters = null)Gets a param by its name or numeric indexpublicmixedgetParameter(mixed$param,mixed$filters = null)Gets a param by its name or numeric indexpublicarraygetParameters()Gets action paramspublicarraygetParams()Gets action paramspublicmixedgetReturnedValue()Returns value returned by the latest dispatched actionpublicboolhasParam( mixed$param )Check if a param existspublicboolisFinished()Checks if the dispatch loop is finished or has more pendentpublicvoidsetActionName( string$actionName )Sets the action name to be dispatchedpublicvoidsetActionSuffix( string$actionSuffix )Sets the default action suffixpublicvoidsetDefaultAction( string$actionName )Sets the default action namepublicvoidsetDefaultNamespace( string$defaultNamespace )Sets the default namespacepublicvoidsetHandlerSuffix( string$handlerSuffix )Sets the default suffix for the handlerpublicvoidsetModuleName( string$moduleName = null )Sets the module name which the application belongs topublicvoidsetNamespaceName( string$namespaceName )Sets the namespace which the controller belongs topublicvoidsetParam(mixed$param,mixed$value)Set a param by its name or numeric indexpublicvoidsetParams( array$params )Sets action params to be dispatchedMethods
dispatch()
public function dispatch(): mixed|bool;Dispatches a handle action taking into account the routing parameters
forward()
public function forward( array $forward ): void;Forwards the execution flow to another controller/action
getActionName()
public function getActionName(): string;Gets last dispatched action name
getActionSuffix()
public function getActionSuffix(): string;Gets the default action suffix
getHandlerSuffix()
public function getHandlerSuffix(): string;Gets the default handler suffix
getParam()
public function getParam(
mixed $param,
mixed $filters = null
): mixed;Gets a param by its name or numeric index
getParameter()
public function getParameter(
mixed $param,
mixed $filters = null
): mixed;Gets a param by its name or numeric index
getParameters()
public function getParameters(): array;Gets action params
getParams()
public function getParams(): array;Gets action params
getReturnedValue()
public function getReturnedValue(): mixed;Returns value returned by the latest dispatched action
hasParam()
public function hasParam( mixed $param ): bool;Check if a param exists
isFinished()
public function isFinished(): bool;Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch
setActionName()
public function setActionName( string $actionName ): void;Sets the action name to be dispatched
setActionSuffix()
public function setActionSuffix( string $actionSuffix ): void;Sets the default action suffix
setDefaultAction()
public function setDefaultAction( string $actionName ): void;Sets the default action name
setDefaultNamespace()
public function setDefaultNamespace( string $defaultNamespace ): void;Sets the default namespace
setHandlerSuffix()
public function setHandlerSuffix( string $handlerSuffix ): void;Sets the default suffix for the handler
setModuleName()
public function setModuleName( string $moduleName = null ): void;Sets the module name which the application belongs to
setNamespaceName()
public function setNamespaceName( string $namespaceName ): void;Sets the namespace which the controller belongs to
setParam()
public function setParam(
mixed $param,
mixed $value
): void;Set a param by its name or numeric index
setParams()
public function setParams( array $params ): void;Sets action params to be dispatched
Dispatcher\Exception
ClassSource on GitHubExceptions thrown in Phalcon\Dispatcher/* will use this class
\ExceptionPhalcon\Dispatcher\Exception
Constants
intEXCEPTION_ACTION_NOT_FOUND = 5intEXCEPTION_CYCLIC_ROUTING = 1intEXCEPTION_HANDLER_NOT_FOUND = 2intEXCEPTION_INVALID_HANDLER = 3intEXCEPTION_INVALID_PARAMS = 4intEXCEPTION_NO_DI = 0Dispatcher\Exceptions\ForwardInInitializeForbidden
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
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
Method Summary
Methods
__construct()
public function __construct();