PHP Class Cake\Console\ShellDispatcher

Consult /bin/cake.php for how this class is used in practice.
Afficher le fichier Open project: cakephp/cakephp Class Usage Examples

Méthodes publiques

Свойство Type Description
$args array Contains arguments parsed from the command line.

Protected Properties

Свойство Type Description
$_aliases array List of connected aliases.

Méthodes publiques

Méthode Description
__construct ( array $args = [], boolean $bootstrap = true ) Constructor
addShortPluginAliases ( ) : array For all loaded plugins, add a short alias
alias ( string $short, string | null $original = null ) : string | false Add an alias for a shell command.
dispatch ( array $extra = [] ) : integer Dispatches a CLI request
findShell ( string $shell ) : Shell Get shell to use, either plugin shell or application shell
help ( ) : void Shows console help. Performs an internal dispatch to the CommandList Shell
resetAliases ( ) : void Clear any aliases that have been set.
run ( array $argv, array $extra = [] ) : integer Run the dispatcher
shiftArgs ( ) : mixed Removes first argument and shifts other arguments up
version ( ) : void Prints the currently installed version of CakePHP. Performs an internal dispatch to the CommandList Shell

Méthodes protégées

Méthode Description
_bootstrap ( ) : boolean Initializes the environment and loads the CakePHP core.
_createShell ( string $className, string $shortName ) : Shell Create the given shell name, and set the plugin property
_dispatch ( array $extra = [] ) : boolean Dispatch a request.
_handleAlias ( string $shell ) : string If the input matches an alias, return the aliased shell name
_initEnvironment ( ) : void Defines current working environment.
_shellExists ( string $shell ) : string | boolean Check if a shell class exists for the given name.

Method Details

__construct() public méthode

The execution of the script is stopped after dispatching the request with a status code of either 0 or 1 according to the result of the dispatch.
public __construct ( array $args = [], boolean $bootstrap = true )
$args array the argv from PHP
$bootstrap boolean Should the environment be bootstrapped.

_bootstrap() protected méthode

Initializes the environment and loads the CakePHP core.
protected _bootstrap ( ) : boolean
Résultat boolean Success.

_createShell() protected méthode

Create the given shell name, and set the plugin property
protected _createShell ( string $className, string $shortName ) : Shell
$className string The class name to instantiate
$shortName string The plugin-prefixed shell name
Résultat Shell A shell instance.

_dispatch() protected méthode

Dispatch a request.
protected _dispatch ( array $extra = [] ) : boolean
$extra array Extra parameters that you can manually pass to the Shell to be dispatched. Built-in extra parameter is : - `requested` : if used, will prevent the Shell welcome message to be displayed
Résultat boolean

_handleAlias() protected méthode

If the input matches an alias, return the aliased shell name
protected _handleAlias ( string $shell ) : string
$shell string Optionally the name of a plugin or alias
Résultat string Shell name with plugin prefix

_initEnvironment() protected méthode

Defines current working environment.
protected _initEnvironment ( ) : void
Résultat void

_shellExists() protected méthode

Check if a shell class exists for the given name.
protected _shellExists ( string $shell ) : string | boolean
$shell string The shell name to look for.
Résultat string | boolean Either the classname or false.

addShortPluginAliases() public méthode

This permits a plugin which implements a shell of the same name to be accessed Using the shell name alone
public addShortPluginAliases ( ) : array
Résultat array the resultant list of aliases

alias() public static méthode

Aliases allow you to call shells by alternate names. This is most useful when dealing with plugin shells that you want to have shorter names for. If you re-use an alias the last alias set will be the one available. ### Usage Aliasing a shell named ClassName: $this->alias('alias', 'ClassName'); Getting the original name for a given alias: $this->alias('alias');
public static alias ( string $short, string | null $original = null ) : string | false
$short string The new short name for the shell.
$original string | null The original full name for the shell.
Résultat string | false The aliased class name, or false if the alias does not exist

dispatch() public méthode

Converts a shell command result into an exit code. Null/True are treated as success. All other return values are an error.
public dispatch ( array $extra = [] ) : integer
$extra array Extra parameters that you can manually pass to the Shell to be dispatched. Built-in extra parameter is : - `requested` : if used, will prevent the Shell welcome message to be displayed
Résultat integer The cli command exit code. 0 is success.

findShell() public méthode

All paths in the loaded shell paths are searched, handles alias dereferencing
public findShell ( string $shell ) : Shell
$shell string Optionally the name of a plugin
Résultat Shell A shell instance.

help() public méthode

Shows console help. Performs an internal dispatch to the CommandList Shell
public help ( ) : void
Résultat void

resetAliases() public static méthode

Clear any aliases that have been set.
public static resetAliases ( ) : void
Résultat void

run() public static méthode

Run the dispatcher
public static run ( array $argv, array $extra = [] ) : integer
$argv array The argv from PHP
$extra array Extra parameters
Résultat integer The exit code of the shell process.

shiftArgs() public méthode

Removes first argument and shifts other arguments up
public shiftArgs ( ) : mixed
Résultat mixed Null if there are no arguments otherwise the shifted argument

version() public méthode

Prints the currently installed version of CakePHP. Performs an internal dispatch to the CommandList Shell
public version ( ) : void
Résultat void

Property Details

$_aliases protected_oe static_oe property

List of connected aliases.
protected static array $_aliases
Résultat array

$args public_oe property

Contains arguments parsed from the command line.
public array $args
Résultat array