ARouter
0.1.0
Annotation based router for your projects
|
Public Member Functions | |
__construct ($controller, $method, $keyedArgs=[]) | |
convertKeyedArgs (array $keyedArgs) | |
execute () | |
getController () | |
getMethod () | |
getKeyedArgs () | |
Handler for producing HTTP response from controller action methods.
Route handler calls provided controller method with provided arguments. Router is responsible for creating correct RouteHandler object for incoming request.
Action method arguments are passed as array in form of ['argument name' => 'argument value']
.
E.g. If you have MyController
class with method function contactPage($name, $message)
the correct handler creation code will be
If you provide less arguments than needed the exception will be thrown on handler creation.
__construct | ( | $controller, | |
$method, | |||
$keyedArgs = [] |
|||
) |
RouteHandler constructor.
object | $controller | Controller object. |
string | $method | Name of controller method. |
array | $keyedArgs | Controller method arguments in form of ['argument name' => 'argument value'] . |
convertKeyedArgs | ( | array | $keyedArgs | ) |
Convert controller method keyed arguments to form compatible with call_user_func_array
array | $keyedArgs | Controller method keyed arguments. |
execute | ( | ) |
Execute route handler and return result.
getController | ( | ) |
Get controller object.
getKeyedArgs | ( | ) |
Get method arguments are passed as array in form of ['argument name' => 'argument value']
.
getMethod | ( | ) |
Get controller method name.