ORM Cache Shell.
Provides a CLI interface to the ORM metadata caching features. This tool is intended to be used by deployment scripts so that you can prevent thundering herd effects on the metadata cache when new versions of your application are deployed, or when migrations requiring updated metadata are required.
_getSchema( )
Helper method to get the schema collection.
false|Cake\Database\Schema\Collection
build( string|null $name null )
Build metadata.
$name
optional null boolean
clear( string|null $name null )
Clear metadata.
$name
optional null boolean
Cake\Console\Shell::clear()
getOptionParser( )
Get the option parser for this shell.
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.
array
__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
integer|boolean
_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 0 )
Stop execution of the current script. Wraps exit() making testing easier.
$status
optional 0 createFile( string $path , string $contents )
Creates a file at given path
$path
$contents
boolean
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'] ]);`
mixed
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 )
Displays a formatted error message and exits the application with status code 1
$title
$message
optional null integer
hasMethod( string $name )
Check to see if this shell has a callable method by the given name.
$name
boolean
hasTask( string $task )
Check to see if this shell has a task with the provided name.
$task
boolean
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 mixed
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 string
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 integer|boolean
param( string $name )
Safely access the values in $this->params.
$name
string|boolean|null
parseDispatchArguments( array $args )
Parses the arguments for the dispatchShell() method.
$args
array
quiet( string|array $message , integer $newlines 1 )
Output at all levels.
$message
$newlines
optional 1 integer|boolean
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 $extra
optional [] requested
: if used, will prevent the Shell welcome message to be displayedmixed
shortPath( string $file )
Makes absolute file path easier to read
$file
string
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.
verbose( string|array $message , integer $newlines 1 )
Output at the verbose level.
$message
$newlines
optional 1 integer|boolean
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 [] string
Cake\Utility\Text::wrap()
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 [] boolean
_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
mixed
_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 object
Cake\Datasource\Exception\MissingModelException
InvalidArgumentException
UnexpectedValueException
modelFactory( string $type , callable $factory )
Register a 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 string|$this
CODE_ERROR, NORMAL, QUIET, VERBOSE |
public Cake\Console\ConsoleOptionParser
An instance of ConsoleOptionParser that has been configured for this class.
public Cake\Console\TaskRegistry
Task Collection for the command, used to create Tasks.
public boolean
If true, the script will ask for permission to perform actions.
true
public string
The name of the plugin the shell belongs to. Is automatically set by ShellDispatcher when a shell is constructed.
null
public array
Contains tasks to load and instantiate
[]
public string
This object's primary model class name. Should be a plural form. CakePHP will not inflect the name.
Example: For an object named 'Comments', the modelClass would be 'Comments'. Plugin classes should use Plugin.Comments
style names to correctly load models from the correct plugin.
© 2005–2016 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.
http://api.cakephp.org/3.1/class-Cake.Shell.OrmCacheShell.html