Base class for console commands.
integer
1 integer
0 $name protected string__construct( )
Constructor
By default CakePHP will construct command objects when building the CommandCollection for your application.
abort( integer $code self::CODE_ERROR )
Halt the the current process with a StopException.
$code optional self::CODE_ERROR Cake\Console\Exception\StopExceptionbuildOptionParser( Cake\Console\ConsoleOptionParser $parser )
Hook method for defining this command's option parser.
Cake\Console\ConsoleOptionParser $parser Cake\Console\ConsoleOptionParserdisplayHelp( Cake\Console\ConsoleOptionParser $parser , Cake\Console\Arguments $args , Cake\Console\ConsoleIo $io )
Output help content
Cake\Console\ConsoleOptionParser $parser Cake\Console\Arguments $args Cake\Console\ConsoleIo $io execute( Cake\Console\Arguments $args , Cake\Console\ConsoleIo $io )
Implement this method with your command's logic.
Cake\Console\Arguments $args Cake\Console\ConsoleIo $io getOptionParser( )
Get the option parser.
You can override buildOptionParser() to define your options & arguments.
Cake\Console\ConsoleOptionParserinitialize( )
Hook method invoked by CakePHP when a command is about to be executed.
Override this method and implement expensive/important setup steps that should not run on every command run. This method will be called before the options and arguments are validated and processed.
run( array $argv , Cake\Console\ConsoleIo $io )
Run the command.
$argv Cake\Console\ConsoleIo $io setName( string $name )
Set the name this command uses in the collection.
Generally invoked by the CommandCollection when the command is added. Required to have at least one space in the name so that the root command can be calculated.
$name setOutputLevel( Cake\Console\Arguments $args , Cake\Console\ConsoleIo $io )
Set the output level based on the Arguments.
Cake\Console\Arguments $args Cake\Console\ConsoleIo $io getTableLocator( )
Gets the table locator.
Cake\ORM\Locator\LocatorInterfacesetTableLocator( Cake\ORM\Locator\LocatorInterface $tableLocator )
Sets the table locator.
Cake\ORM\Locator\LocatorInterface $tableLocator 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\LocatorInterfacelog( 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 [] _setModelClass( string $name )
Set the modelClass and modelKey properties based on conventions.
If the properties are already set they will not be overwritten
$name getModelType( )
Get the model type to be used by this class
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\RepositoryInterfaceCake\Datasource\Exception\MissingModelExceptionmodelFactory( 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\ModelAwareTraitsetModelType( string $modelType )
Set the model type to be used by this class
$modelType
© 2005–2018 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.6/class-Cake.Console.Command.html