lithium\action\Dispatcher::run()
Dispatches a request based on a request object (an instance or subclass of
lithium\net\http\Request
).
Parameters
-
object
$request
An instance of a request object (usually
lithium\action\Request
) with HTTP request information. -
array
$options
Returns
mixedReturns the value returned from the callable object retrieved from
Dispatcher::_callable()
, which is either a string or an instance of
lithium\action\Response
.
Filter
Allows to perform actions very early or late in the request.
Source
public static function run($request, array $options = []) {
$params = compact('request', 'options');
return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) {
$router = static::$_classes['router'];
$request = $params['request'];
$options = $params['options'];
if (($result = $router::process($request)) instanceof Response) {
return $result;
}
$params = static::applyRules($result->params);
if (!$params) {
throw new DispatchException('Could not route request.');
}
$callable = static::_callable($result, $params, $options);
return static::_call($callable, $result, $params);
});
}