lithium\action\Dispatcher::_callable()

protected static method

Accepts parameters generated by the Router class in Dispatcher::run(), and produces a callable controller object. By default, this method uses the 'controller' path lookup configuration in Libraries::locate() to return a callable object.

Parameters

  • object $request

    The instance of the Request class either passed into or generated by Dispatcher::run().

  • array $params

    The parameter array generated by routing the request.

  • array $options

    Not currently implemented.

Returns

object

Returns a callable object which the request will be routed to.

Filter

This method can be filtered.

Source

	protected static function _callable($request, $params, $options) {
		$params = compact('request', 'params', 'options');

		return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) {
			$options = ['request' => $params['request']] + $params['options'];
			$controller = $params['params']['controller'];

			try {
				return Libraries::instance('controllers', $controller, $options);
			} catch (ClassNotFoundException $e) {
				throw new DispatchException("Controller `{$controller}` not found.", 2001, $e);
			}
		});
	}