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.
파일 보기
프로젝트 열기: unionofrad/lithium
1 사용 예제들
보호된 프로퍼티들
프로퍼티 |
타입 |
설명 |
|
$_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). |
|
보호된 메소드들
메소드 상세
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`. |
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. |
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. |
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. |
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.
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.
protected static array $_rules |
리턴 |
array |
|