PHP Класс lithium\console\Dispatcher

The console dispatcher is responsible for accepting requests from scripts called from the command line, and executing the appropriate Command class(es). The run() method accepts an instance of lithium\console\Request, which encapsulates the console environment and any command-line parameters passed to the script. Dispatcher then invokes lithium\console\Router to determine the correct Command class to invoke, and which method should be called.
Наследование: extends lithium\core\StaticObject
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_classes array Class must implement a parse() method, which must return an array with (at a minimum) 'command' and 'action' keys.
$_rules array Each key in the array represents a 'rule'; if a key that matches the rule is present (and not empty) in a route, (i.e. the result of lithium\console\Router::parse()) then the rule's value will be applied to the route before it is dispatched. When applying a rule, any array elements array elements of the flag which are present in the route will be modified using a lithium\util\String::insert()-formatted string.

Открытые методы

Метод Описание
applyRules ( array $params ) : array Attempts to apply a set of formatting rules from $_rules to a $params array.
config ( array $config = [] ) : array Used to set configuration parameters for the Dispatcher.
run ( object $request = null, array $options = [] ) : object Dispatches a request based on a request object (an instance of lithium\console\Request).

Защищенные методы

Метод Описание
_call ( string $callable, string $request, string $params ) : mixed Calls a given command with the appropriate action.
_callable ( object $request, array $params, array $options ) : class Determines which command to use for current request.

Описание методов

_call() защищенный статический Метод

This method is responsible for calling a $callable command and returning its result.
protected static _call ( string $callable, string $request, string $params ) : mixed
$callable string The callable command.
$request string The associated `Request` object.
$params string Additional params that should be passed along.
Результат mixed Returns the result of the called action, typically `true` or `false`.

_callable() защищенный статический Метод

Determines which command to use for current request.
protected static _callable ( object $request, array $params, array $options ) : class
$request object An instance of a `Request` object.
$params array Request params that can be accessed inside the filter.
$options array
Результат class lithium\console\Command Returns the instantiated command object.

applyRules() публичный статический Метод

Each formatting rule is applied if the key of the rule in $_rules is present and not empty in $params. Also performs sanity checking against $params to ensure that no value matching a rule is present unless the rule check passes.
public static applyRules ( array $params ) : array
$params array An array of route parameters to which rules will be applied.
Результат array Returns the `$params` array with formatting rules applied to array values.

config() публичный статический Метод

Used to set configuration parameters for the Dispatcher.
public static config ( array $config = [] ) : array
$config array Optional configuration params.
Результат array If no parameters are passed, returns an associative array with the current configuration, otherwise returns null.

run() публичный статический Метод

If $request is null, a new request object is instantiated based on the value of the 'request' key in the $_classes array.
public static run ( object $request = null, array $options = [] ) : object
$request object An instance of a request object with console request information. If `null`, an instance will be created.
$options array
Результат object The command action result which is an instance of `lithium\console\Response`.

Описание свойств

$_classes защищенное статическое свойство

Class must implement a parse() method, which must return an array with (at a minimum) 'command' and 'action' keys.
См. также: lithium\console\Router::parse()
protected static array $_classes
Результат array

$_rules защищенное статическое свойство

Each key in the array represents a 'rule'; if a key that matches the rule is present (and not empty) in a route, (i.e. the result of lithium\console\Router::parse()) then the rule's value will be applied to the route before it is dispatched. When applying a rule, any array elements array elements of the flag which are present in the route will be modified using a lithium\util\String::insert()-formatted string.
См. также: lithium\console\Dispatcher::config()
См. также: lithium\util\String::insert()
protected static array $_rules
Результат array