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 = array()) {
$router = static::$_classes['router'];
$params = compact('request', 'options');
return static::_filter(__FUNCTION__, $params, function($self, $params) use ($router) {
$request = $params['request'];
$options = $params['options'];
if (($result = $router::process($request)) instanceof Response) {
return $result;
}
$params = $self::applyRules($result->params);
if (!$params) {
throw new DispatchException('Could not route request.');
}
$callable = $self::invokeMethod('_callable', array($result, $params, $options));
return $self::invokeMethod('_call', array($callable, $result, $params));
});
}