lithium\console\Dispatcher::_call()

protected static method

Calls a given command with the appropriate action.

This method is responsible for calling a $callable command and returning its result.

Parameters

  • string $callable

    The callable command.

  • string $request

    The associated Request object.

  • string $params

    Additional params that should be passed along.

Returns

mixed

Returns the result of the called action, typically true or false.

Filter

This method can be filtered.

Source

	protected static function _call($callable, $request, $params) {
		$params = compact('callable', 'request', 'params');
		return static::_filter(__FUNCTION__, $params, function($self, $params) {
			if (is_callable($callable = $params['callable'])) {
				$request = $params['request'];
				$params = $params['params'];

				if (!method_exists($callable, $params['action'])) {
					array_unshift($params['args'], $request->params['action']);
					$params['action'] = 'run';
				}
				$isHelp = (
					!empty($params['help']) || !empty($params['h']) ||
					!method_exists($callable, $params['action'])
				);
				if ($isHelp) {
					$params['action'] = '_help';
				}
				return $callable($params['action'], $params['args']);
			}
			throw new UnexpectedValueException("Callable `{$callable}` is actually not callable.");
		});
	}