PHP Класс Cake\Console\ShellDispatcher

Consult /bin/cake.php for how this class is used in practice.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$args array Contains arguments parsed from the command line.

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

Свойство Тип Описание
$_aliases array List of connected aliases.

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

Метод Описание
__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

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

Метод Описание
_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.

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

__construct() публичный метод

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() защищенный метод

Initializes the environment and loads the CakePHP core.
protected _bootstrap ( ) : boolean
Результат boolean Success.

_createShell() защищенный метод

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
Результат Shell A shell instance.

_dispatch() защищенный метод

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
Результат boolean

_handleAlias() защищенный метод

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
Результат string Shell name with plugin prefix

_initEnvironment() защищенный метод

Defines current working environment.
protected _initEnvironment ( ) : void
Результат void

_shellExists() защищенный метод

Check if a shell class exists for the given name.
protected _shellExists ( string $shell ) : string | boolean
$shell string The shell name to look for.
Результат string | boolean Either the classname or false.

addShortPluginAliases() публичный метод

This permits a plugin which implements a shell of the same name to be accessed Using the shell name alone
public addShortPluginAliases ( ) : array
Результат array the resultant list of aliases

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

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.
Результат string | false The aliased class name, or false if the alias does not exist

dispatch() публичный метод

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
Результат integer The cli command exit code. 0 is success.

findShell() публичный метод

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
Результат Shell A shell instance.

help() публичный метод

Shows console help. Performs an internal dispatch to the CommandList Shell
public help ( ) : void
Результат void

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

Clear any aliases that have been set.
public static resetAliases ( ) : void
Результат void

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

Run the dispatcher
public static run ( array $argv, array $extra = [] ) : integer
$argv array The argv from PHP
$extra array Extra parameters
Результат integer The exit code of the shell process.

shiftArgs() публичный метод

Removes first argument and shifts other arguments up
public shiftArgs ( ) : mixed
Результат mixed Null if there are no arguments otherwise the shifted argument

version() публичный метод

Prints the currently installed version of CakePHP. Performs an internal dispatch to the CommandList Shell
public version ( ) : void
Результат void

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

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

List of connected aliases.
protected static array $_aliases
Результат array

$args публичное свойство

Contains arguments parsed from the command line.
public array $args
Результат array