extends abstract class Phalcon\Dispatcher
implements Phalcon\Events\EventsAwareInterface, Phalcon\Di\InjectionAwareInterface, Phalcon\DispatcherInterface, Phalcon\Mvc\DispatcherInterface
Dispatching is the process of taking the request object, extracting the module name, controller name, action name, and optional parameters contained in it, and then instantiating a controller and calling an action of that controller.
$di = new \Phalcon\Di(); $dispatcher = new \Phalcon\Mvc\Dispatcher(); $dispatcher->setDI($di); $dispatcher->setControllerName("posts"); $dispatcher->setActionName("index"); $dispatcher->setParams([]); $controller = $dispatcher->dispatch();
Sets the default controller suffix
Sets the default controller name
Sets the controller name to be dispatched
Gets last dispatched controller name
Gets previous dispatched namespace name
Gets previous dispatched controller name
Gets previous dispatched action name
Throws an internal exception
Handles a user exception
Possible controller class name that will be located to dispatch the request
Returns the latest dispatched controller
Returns the active controller in the dispatcher
Sets the dependency injector
Returns the internal dependency injector
Sets the events manager
Returns the internal event manager
Sets the default action suffix
Gets the default action suffix
Sets the module where the controller is (only informative)
Gets the module where the controller class is
Sets the namespace where the controller class is
Gets a namespace to be prepended to the current handler name
Sets the default namespace
Returns the default namespace
Sets the default action name
Sets the action name to be dispatched
Gets the latest dispatched action name
Sets action params to be dispatched
Gets action params
Set a param by its name or numeric index
Gets a param by its name or numeric index
Check if a param exists
Returns the current method to be/executed in the dispatcher
Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch
Sets the latest returned value by an action manually
Returns value returned by the latest dispatched action
Enable/Disable model binding during dispatch
$di->set('dispatcher', function() { $dispatcher = new Dispatcher(); $dispatcher->setModelBinding(true, 'cache'); return $dispatcher; });
Enable model binding during dispatch
$di->set('dispatcher', function() { $dispatcher = new Dispatcher(); $dispatcher->setModelBinder(new Binder(), 'cache'); return $dispatcher; });
Gets model binder
Dispatches a handle action taking into account the routing parameters
Dispatches a handle action taking into account the routing parameters
Forwards the execution flow to another controller/action Dispatchers are unique per module. Forwarding between modules is not allowed
$this->dispatcher->forward( [ "controller" => "posts", "action" => "index", ] );
Check if the current executed action was forwarded by another one
Possible class name that will be located to dispatch the request
...
Returns bound models from binder instance
class UserController extends Controller { public function showAction(User $user) { $boundModels = $this->dispatcher->getBoundModels(); // return array with $user } }
Set empty properties to their defaults (where defaults are available)
© 2011–2017 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Dispatcher.html