Class ShellDispatcher
Shell dispatcher handles dispatching cli commands.
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Console/ShellDispatcher.php
Properties summary
-
$args
publicContains arguments parsed from the command line.array
-
$params
publicContains command switches parsed from the command line.array
Method Summary
- __construct() publicConstructor
- _bootstrap() protectedInitializes the environment and loads the CakePHP core.
- _getShell() protectedGet shell to use, either plugin shell or application shell
- _initConstants() protectedDefines core configuration.
- _initEnvironment() protectedDefines current working environment.
- _isAbsolutePath() protectedChecks whether the given path is absolute or relative.
- _isWindowsPath() protectedChecks whether the given path is Window OS path.
- _parsePaths() protectedParses out the paths from from the argv
- _stop() protectedStop execution of the current script
- dispatch() publicDispatches a CLI request
- help() publicShows console help. Performs an internal dispatch to the CommandList Shell
- parseParams() publicParses command line options and extracts the directory paths from $params
- Run the dispatcher
- setErrorHandlers() public
Set the error/exception handlers for the console based on the
Error.consoleHandler
, andException.consoleHandler
values if they are set. If they are not set, the default ConsoleErrorHandler will be used. - shiftArgs() publicRemoves first argument and shifts other arguments up
Method Detail
__construct()source public
__construct( array $args array() , boolean $bootstrap true )
Constructor
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.
Parameters
- array
$args
optional array() - the argv from PHP
- boolean
$bootstrap
optional true - Should the environment be bootstrapped.
_bootstrap()source protected
_bootstrap( )
Initializes the environment and loads the CakePHP core.
Returns
booleanSuccess.
_getShell()source protected
_getShell( string $shell )
Get shell to use, either plugin shell or application shell
All paths in the loaded shell paths are searched.
Parameters
- string
$shell
- Optionally the name of a plugin
Returns
mixedAn object
Throws
MissingShellException
when errors are encountered.
_initEnvironment()source protected
_initEnvironment( )
Defines current working environment.
Throws
CakeException
_isAbsolutePath()source protected
_isAbsolutePath( string $path )
Checks whether the given path is absolute or relative.
Parameters
- string
$path
- absolute or relative path.
Returns
boolean_isWindowsPath()source protected
_isWindowsPath( string $path )
Checks whether the given path is Window OS path.
Parameters
- string
$path
- absolute path.
Returns
boolean_parsePaths()source protected
_parsePaths( array $args )
Parses out the paths from from the argv
Parameters
- array
$args
- The argv to parse.
_stop()source protected
_stop( integer|string $status 0 )
Stop execution of the current script
Parameters
- integer|string
$status
optional 0 - see http://php.net/exit for values
dispatch()source public
dispatch( )
Dispatches a CLI request
Returns
booleanThrows
MissingShellMethodException
help()source public
help( )
Shows console help. Performs an internal dispatch to the CommandList Shell
parseParams()source public
parseParams( array $args )
Parses command line options and extracts the directory paths from $params
Parameters
- array
$args
- Parameters to parse
run()source public static
run( array $argv )
Run the dispatcher
Parameters
- array
$argv
- The argv from PHP
setErrorHandlers()source public
setErrorHandlers( )
Set the error/exception handlers for the console based on the Error.consoleHandler
, and Exception.consoleHandler
values if they are set. If they are not set, the default ConsoleErrorHandler will be used.
shiftArgs()source public
shiftArgs( )
Removes first argument and shifts other arguments up
Returns
mixedNull if there are no arguments otherwise the shifted argument
Properties detail
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.10/class-ShellDispatcher.html