Shell for tasks related to plugins.
$tasks
public array
OptionParser
, Tasks
, _io
, _taskMap
, args
, command
, interactive
, name
, params
, plugin
, taskNames
_tableLocator
_modelFactories
, _modelType
, modelClass
getOptionParser( )
Gets the option parser instance and configures it.
Cake\Console\ConsoleOptionParser
Cake\Console\Shell::getOptionParser()
__construct( Cake\Console\ConsoleIo $io null )
Constructs this Shell instance.
Cake\Console\ConsoleIo
$io
optional null __debugInfo( )
Returns an array that can be used to describe the internal state of this object.
__get( string $name )
Overload get for lazy building of tasks
$name
Cake\Console\Shell
_displayHelp( string $command )
Display the help in the correct format
$command
_setOutputLevel( )
Set the output level based on the parameters.
This reconfigures both the output level for out() and the configured stdout/stderr logging
_stop( integer|string $status self::CODE_SUCCESS )
Stop execution of the current script. Raises a StopException to try and halt the execution.
$status
optional self::CODE_SUCCESS Cake\Console\Exception\StopException
abort( string $message , integer $exitCode self::CODE_ERROR )
Displays a formatted error message and exits the application with status code 1
$message
$exitCode
optional self::CODE_ERROR Cake\Console\Exception\StopException
clear( )
Clear the console
createFile( string $path , string $contents )
Creates a file at given path
$path
$contents
dispatchShell( )
Dispatch a command to another Shell. Similar to Object::requestAction() but intended for running shells from other shells.
With a string command:
return $this->dispatchShell('schema create DbAcl');
Avoid using this form if you have string arguments, with spaces in them. The dispatched will be invoked incorrectly. Only use this form for simple command dispatching.
With an array command:
return $this->dispatchShell('schema', 'create', 'i18n', '--dry');
With an array having two key / value pairs: - command
can accept either a string or an array. Represents the command to dispatch - extra
can accept an array of extra parameters to pass on to the dispatcher. This parameters will be available in the param
property of the called Shell
return $this->dispatchShell([ 'command' => 'schema create DbAcl', 'extra' => ['param' => 'value'] ]);
or
return $this->dispatchShell([ 'command' => ['schema', 'create', 'DbAcl'], 'extra' => ['param' => 'value'] ]);
err( string|array|null $message null , integer $newlines 1 )
Outputs a single or multiple error messages to stderr. If no parameters are passed outputs just a newline.
$message
optional null $newlines
optional 1 error( string $title , string|null $message null , integer $exitCode self::CODE_ERROR )
Displays a formatted error message and exits the application with status code 1
$title
$message
optional null $exitCode
optional self::CODE_ERROR Cake\Console\Exception\StopException
hasMethod( string $name )
Check to see if this shell has a callable method by the given name.
$name
hasTask( string $task )
Check to see if this shell has a task with the provided name.
$task
helper( string $name , array $settings [] )
Render a Console Helper
Create and render the output for a helper object. If the helper object has not already been loaded, it will be loaded and constructed.
$name
$settings
optional [] Cake\Console\Helper
hr( integer $newlines 0 , integer $width 63 )
Outputs a series of minus characters to the standard output, acts as a visual separator.
$newlines
optional 0 $width
optional 63 in( string $prompt , string|array|null $options null , string|null $default null )
Prompts the user for input, and returns it.
$prompt
$options
optional null $default
optional null info( string|array|null $message null , integer $newlines 1 , integer $level Cake\Shell\Shell::NORMAL )
Convenience method for out() that wraps message between tag
$message
optional null $newlines
optional 1 $level
optional Cake\Shell\Shell::NORMAL initialize( )
Initializes the Shell acts as constructor for subclasses allows configuration of tasks prior to shell execution
io( Cake\Console\ConsoleIo $io null )
Get/Set the io object for this shell.
Cake\Console\ConsoleIo
$io
optional null Cake\Console\ConsoleIo
nl( integer $multiplier 1 )
Returns a single or multiple linefeeds sequences.
$multiplier
optional 1 out( string|array|null $message null , integer $newlines 1 , integer $level Cake\Shell\Shell::NORMAL )
Outputs a single or multiple messages to stdout. If no parameters are passed outputs just a newline.
There are 3 built-in output level. Shell::QUIET, Shell::NORMAL, Shell::VERBOSE. The verbose and quiet output levels, map to the verbose
and quiet
output switches present in most shells. Using Shell::QUIET for a message means it will always display. While using Shell::VERBOSE means it will only display when verbose output is toggled.
$message
optional null $newlines
optional 1 $level
optional Cake\Shell\Shell::NORMAL param( string $name )
Safely access the values in $this->params.
$name
parseDispatchArguments( array $args )
Parses the arguments for the dispatchShell() method.
$args
Arguments fetch from the dispatchShell() method with func_get_args()
First value has to be an array of the command arguments. Second value has to be an array of extra parameter to pass on to the dispatcher
quiet( string|array $message , integer $newlines 1 )
Output at all levels.
$message
$newlines
optional 1 runCommand( array $argv , boolean $autoMethod false , array $extra [] )
Runs the Shell with the provided argv.
Delegates calls to Tasks and resolves methods inside the class. Commands are looked up with the following order:
main()
method.If a shell implements a main()
method, all missing method calls will be sent to main()
with the original method name in the argv.
For tasks to be invoked they must be exposed as subcommands. If you define any subcommands, you must define all the subcommands your shell needs, whether they be methods on this class or methods on tasks.
$argv
$autoMethod
optional false Set to true to allow any public method to be called even if it was not defined as a subcommand. This is used by ShellDispatcher to make building simple shells easy.
$extra
optional [] 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
shortPath( string $file )
Makes absolute file path easier to read
$file
startup( )
Starts up the Shell and displays the welcome message. Allows for checking and configuring prior to command or main execution
Override this method if you want to remove the welcome information, or otherwise modify the pre-command flow.
success( string|array|null $message null , integer $newlines 1 , integer $level Cake\Shell\Shell::NORMAL )
Convenience method for out() that wraps message between tag
$message
optional null $newlines
optional 1 $level
optional Cake\Shell\Shell::NORMAL verbose( string|array $message , integer $newlines 1 )
Output at the verbose level.
$message
$newlines
optional 1 warn( string|array|null $message null , integer $newlines 1 )
Convenience method for err() that wraps message between tag
$message
optional null $newlines
optional 1 wrapText( string $text , integer|array $options [] )
Wrap a block of text. Allows you to set the width, and indenting on a block of text.
width
The width to wrap to. Defaults to 72wordWrap
Only wrap on words breaks (spaces) Defaults to true.indent
Indent the text with the string provided. Defaults to null.$text
$options
optional [] tableLocator( Cake\ORM\Locator\LocatorInterface $tableLocator null )
Sets the table locator. If no parameters are passed, it will return the currently used locator.
Cake\ORM\Locator\LocatorInterface
$tableLocator
optional null Cake\ORM\Locator\LocatorInterface
log( mixed $msg , integer|string $level LogLevel::ERROR , string|array $context [] )
Convenience method to write a message to Log. See Log::write() for more information on writing to logs.
$msg
$level
optional LogLevel::ERROR $context
optional [] _mergeProperty( string $property , array $parentClasses , array $options )
Merge a single property with the values declared in all parent classes.
$property
$parentClasses
$options
_mergePropertyData( array $current , array $parent , boolean $isAssoc )
Merge each of the keys in a property together.
$current
$parent
$isAssoc
_mergeVars( array $properties , array $options [] )
Merge the list of $properties with all parent classes of the current class.
associative
- A list of properties that should be treated as associative arrays. Properties in this list will be passed through Hash::normalize() before merging.$properties
$options
optional [] _setModelClass( string $name )
Set the modelClass and modelKey properties based on conventions.
If the properties are already set they will not be overwritten
$name
loadModel( string|null $modelClass null , string|null $modelType null )
Loads and constructs repository objects required by this object
Typically used to load ORM Table objects as required. Can also be used to load other types of repository objects your application uses.
If a repository provider does not return an object a MissingModelException will be thrown.
$modelClass
optional null $modelType
optional null Cake\Datasource\RepositoryInterface
Cake\Datasource\Exception\MissingModelException
modelFactory( string $type , callable $factory )
Override a existing callable to generate repositories of a given type.
$type
$factory
modelType( string|null $modelType null )
Set or get the model type to be used by this class
$modelType
optional null Cake\Datasource\ModelAwareTrait
public Cake\Shell\Task\AssetsTask
public Cake\Shell\Task\LoadTask
public Cake\Shell\Task\UnloadTask
© 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/3.4/class-Cake.Shell.PluginShell.html