$args
$args : array
Contains arguments parsed from the command line.
Allows injecting mock IO into shells
Consult /bin/cake.php for how this class is used in practice.
$_io : \Cake\Console\ConsoleIo
__construct(array $args = array(), boolean $bootstrap = true, \Cake\Console\ConsoleIo $io = null)
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.
array | $args | Argument array |
boolean | $bootstrap | Initialize environment |
\Cake\Console\ConsoleIo | $io | ConsoleIo |
alias(string $short, string|null $original = null) : string|false
Add an alias for a shell command.
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.
Aliasing a shell named ClassName:
$this->alias('alias', 'ClassName');
Getting the original name for a given alias:
$this->alias('alias');
string | $short | The new short name for the shell. |
string|null | $original | The original full name for the shell. |
The aliased class name, or false if the alias does not exist
dispatch(array $extra = array()) : integer
Dispatches a CLI request
Converts a shell command result into an exit code. Null/True are treated as success. All other return values are an error.
array | $extra | Extra parameters that you can manually pass to the Shell to be dispatched. Built-in extra parameter is :
|
The cli command exit code. 0 is success.
findShell(string $shell) : \Cake\Console\Shell
Get shell to use, either plugin shell or application shell
All paths in the loaded shell paths are searched, handles alias dereferencing
string | $shell | Optionally the name of a plugin |
when errors are encountered.
A shell instance.
_dispatch(array $extra = array()) : boolean|integer|null
Dispatch a request.
array | $extra | Extra parameters that you can manually pass to the Shell to be dispatched. Built-in extra parameter is :
|
_createShell(string $className, string $shortName) : \Cake\Console\Shell
Injects mock and stub io components into the shell
string | $className | Class name |
string | $shortName | Short name |
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @since 3.5.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\TestSuite;
use Cake\Console\ShellDispatcher;
/**
* Allows injecting mock IO into shells
*/
class LegacyShellDispatcher extends ShellDispatcher
{
/**
* @var \Cake\Console\ConsoleIo
*/
protected $_io;
/**
* Constructor
*
* @param array $args Argument array
* @param bool $bootstrap Initialize environment
* @param \Cake\Console\ConsoleIo $io ConsoleIo
*/
public function __construct($args = [], $bootstrap = true, $io = null)
{
$this->_io = $io;
parent::__construct($args, $bootstrap);
}
/**
* Injects mock and stub io components into the shell
*
* @param string $className Class name
* @param string $shortName Short name
* @return \Cake\Console\Shell
*/
protected function _createShell($className, $shortName)
{
list($plugin) = pluginSplit($shortName);
$instance = new $className($this->_io);
$instance->plugin = trim($plugin, '.');
return $instance;
}
}