ExtractTask Class Info:
- Class Declaration:
class ExtractTask extends AppShell
- File name:
- Cake/Console/Command/Task/ExtractTask.php
- Description:
Language string extractor
- Class Inheritance
- Package
- Cake.Console.Command.Task
Properties:
-
args array
Contains arguments parsed from the command line.
-
command string
The command (method/task) that is being run.
-
_exclude array
An array of directories to exclude.
-
_extractValidation boolean
Holds whether this call should extract model validation messages
-
_file string
Current file being processed
-
_files array
Files from where to extract
-
interactive boolean
If true, the script will ask for permission to perform actions.
-
_merge boolean
Merge all domains string into the default.pot file
-
name string
The name of the shell in camelized.
-
OptionParser ConsoleOptionParser
An instance of ConsoleOptionParser that has been configured for this class.
-
_output string
Destination path
-
params array
Contains command switches parsed from the command line.
-
_paths string
Paths to use when looking for strings
-
plugin string
The name of the plugin the shell belongs to. Is automatically set by ShellDispatcher when a shell is constructed.
-
stderr ConsoleOutput
stderr object.
-
stdin ConsoleInput
stdin object
-
stdout ConsoleOutput
stdout object.
-
_storage string
Contains all content waiting to be write
-
_taskMap string
Normalized map of tasks.
-
taskNames array
Contains the loaded tasks
-
Tasks TaskCollection
Task Collection for the command, used to create Tasks.
-
tasks array
Contains tasks to load and instantiate
-
_tokens array
Extracted tokens
-
_translations array
Extracted strings indexed by domain.
-
uses array
Contains models to load and instantiate
-
_validationDomain boolean
Holds the validation string domain to use for validation messages when extracting
Method Summary:
- _addTranslation( $domain, $msgid, $details = array ( ) )
- _buildFiles( )
- _checkUnitTest( )
- clear( )
- __construct( $stdout = NULL, $stderr = NULL, $stdin = NULL )
- _controllerName( $name )
- _controllerPath( $name )
- createFile( $path, $contents )
- dispatchMethod( $method, $params = array ( ) )
- dispatchShell( )
- _displayHelp( $command )
- err( $message = NULL, $newlines = 1 )
- error( $title, $message = NULL )
- execute( )
- _extract( )
- _extractTokens( )
- _extractValidationMessages( )
- _formatString( $string )
- __get( $name )
- _getInput( $prompt, $options, $default )
- getOptionParser( )
- _getPaths( )
- _getStrings( $position, $target )
- hasMethod( $name )
- hasTask( $task )
- hr( $newlines = 0, $width = 63 )
- in( $prompt, $options = NULL, $default = NULL )
- initialize( )
- _isExtractingApp( )
- _loadModels( )
- loadTasks( )
- log( $msg, $type = 2 )
- _markerError( $file, $line, $marker, $count )
- _mergeVars( $properties, $class, $normalize = true )
- _modelKey( $name )
- _modelName( $name )
- _modelNameFromKey( $key )
- nl( $multiplier = 1 )
- out( $message = NULL, $newlines = 1, $level = 1 )
- _parse( $functionName, $map )
- _pluginPath( $pluginName )
- _pluralHumanName( $name )
- _pluralName( $name )
- _processValidationRules( $field, $rules, $file, $domain )
- requestAction( $url, $extra = array ( ) )
- runCommand( $command, $argv )
- _searchFiles( )
- _set( $properties = array ( ) )
- shortPath( $file )
- _singularHumanName( $name )
- _singularName( $name )
- startup( )
- _stop( $status = 0 )
- _store( $domain, $header, $sentence )
- toString( )
- _welcome( )
- wrapText( $text, $options = array ( ) )
- _writeFiles( )
- _writeHeader( )
_addTranslation
topAdd a translation to the internal translations property
Takes care of duplicate translations
- Parameters:
-
-
string $domain required
-
string $msgid required
-
array $details optional array ( )
-
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 220
_buildFiles
topBuild the translate template file contents out of obtained strings
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 480
- Return
void
_checkUnitTest
topAction to create a Unit Test
- Method defined in:
- Cake/Console/Shell.php on line 682
- Return
boolean Success
clear
topClear the console
- Method defined in:
- Cake/Console/Shell.php on line 627
- Return
void
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::clear
__construct
topConstructs this Shell instance.
- Parameters:
-
-
ConsoleOutput $stdout optional NULL
A ConsoleOutput object for stdout.
-
ConsoleOutput $stderr optional NULL
A ConsoleOutput object for stderr.
-
ConsoleInput $stdin optional NULL
A ConsoleInput object for stdin.
-
- Method defined in:
- Cake/Console/Shell.php on line 156
_controllerName
topCreates the proper controller plural name for the specified controller class name
- Parameters:
-
-
string $name required
Controller class name
-
- Method defined in:
- Cake/Console/Shell.php on line 729
- Return
string Controller plural name
_controllerPath
topCreates the proper controller path for the specified controller class name
- Parameters:
-
-
string $name required
Controller class name
-
- Method defined in:
- Cake/Console/Shell.php on line 719
- Return
string Path to controller
createFile
topCreates a file at given path
- Parameters:
-
-
string $path required
Where to put the file.
-
string $contents required
Content to put in the file.
-
- Method defined in:
- Cake/Console/Shell.php on line 645
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::createFile
dispatchMethod
topCalls a method on this object with the given parameters. Provides an OO wrapper
for call_user_func_array
- Parameters:
-
-
string $method required
Name of the method to call
-
array $params optional array ( )
Parameter list to use when calling $method
-
- Method defined in:
- Cake/Core/Object.php on line 110
- Return
mixed Returns the result of the method call
dispatchShell
topDispatch a command to another Shell. Similar to Object::requestAction() but intended for running shells from other shells.
Usage:
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');
- Method defined in:
- Cake/Console/Shell.php on line 326
- Return
mixed The return of the other shell.
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::dispatchShell
_displayHelp
topDisplay the help in the correct format
- Parameters:
-
-
string $command required
-
- Method defined in:
- Cake/Console/Shell.php on line 401
- Return
void
err
topOutputs a single or multiple error messages to stderr. If no parameters are passed outputs just a newline.
- Parameters:
-
-
mixed $message optional NULL
A string or a an array of strings to output
-
integer $newlines optional 1
Number of newlines to append
-
- Method defined in:
- Cake/Console/Shell.php on line 574
- Return
void
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::err
error
topDisplays a formatted error message and exits the application with status code 1
- Parameters:
-
-
string $title required
Title of the error
-
string $message optional NULL
An optional error message
-
- Method defined in:
- Cake/Console/Shell.php on line 612
- Return
void
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::error
execute
topExecution method always used for tasks
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 144
- Return
void
_extract
top_extractTokens
topExtract tokens out of all files to be processed
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 312
- Return
void
_extractValidationMessages
topLooks for models in the application and extracts the validation messages to be added to the translation map
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 398
- Return
void
_formatString
topFormat a string to be added as a translatable string
- Parameters:
-
-
string $string required
String to format
-
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 630
- Return
string Formatted string
__get
topOverload get for lazy building of tasks
- Parameters:
-
-
string $name required
-
- Method defined in:
- Cake/Console/Shell.php on line 431
- Return
Shell Object of Task
_getInput
topPrompts the user for input, and returns it.
- Parameters:
-
-
string $prompt required
Prompt text.
-
mixed $options required
Array or string of options.
-
string $default required
Default input value.
-
- Method defined in:
- Cake/Console/Shell.php on line 489
- Return
Either the default value, or the user-provided input.
getOptionParser
topGet & configure the option parser
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 272
- Return
void
_getPaths
topMethod to interact with the User and get path selections.
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 112
- Return
void
_getStrings
topGet the strings from the position forward
- Parameters:
-
-
integer $position required
Actual position on tokens array
-
integer $target required
Number of strings to extract
-
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 602
- Return
array Strings extracted
hasMethod
topCheck to see if this shell has a callable method by the given name.
- Parameters:
-
-
string $name required
The method name to check.
-
- Method defined in:
- Cake/Console/Shell.php on line 290
- Return
boolean
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::hasMethod
hasTask
topCheck to see if this shell has a task with the provided name.
- Parameters:
-
-
string $task required
The task name to check.
-
- Method defined in:
- Cake/Console/Shell.php on line 279
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::hasTask
hr
topOutputs a series of minus characters to the standard output, acts as a visual separator.
- Parameters:
-
-
integer $newlines optional 0
Number of newlines to pre- and append
-
integer $width optional 63
Width of the line, defaults to 63
-
- Method defined in:
- Cake/Console/Shell.php on line 597
- Return
void
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::hr
in
topPrompts the user for input, and returns it.
- Parameters:
-
-
string $prompt required
Prompt text.
-
mixed $options optional NULL
Array or string of options.
-
string $default optional NULL
Default input value.
-
- Method defined in:
- Cake/Console/Shell.php on line 452
- Return
mixed Either the default value, or the user-provided input.
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::in
initialize
topInitializes the Shell acts as constructor for subclasses allows configuration of tasks prior to shell execution
- Method defined in:
- Cake/Console/Shell.php on line 192
_isExtractingApp
topReturns whether this execution is meant to extract string only from directories in folder represented by the APP constant, i.e. this task is extracting strings from same application.
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 713
- Return
boolean
_loadModels
topIf $uses = true Loads AppModel file and constructs AppModel class makes $this->AppModel available to subclasses If public $uses is an array of models will load those models
- Method defined in:
- Cake/Console/Shell.php on line 232
- Return
boolean
loadTasks
topLoads tasks defined in public $tasks
- Method defined in:
- Cake/Console/Shell.php on line 261
- Return
boolean
log
topConvenience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.
- Parameters:
-
-
string $msg required
Log message
-
integer $type optional 2
Error type constant. Defined in app/Config/core.php.
-
- Method defined in:
- Cake/Core/Object.php on line 149
- Return
boolean Success of log write
_markerError
topIndicate an invalid marker on a processed file
- Parameters:
-
-
string $file required
File where invalid marker resides
-
integer $line required
Line number
-
string $marker required
Marker found
-
integer $count required
Count
-
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 651
- Return
void
_mergeVars
topMerges this objects $property with the property in $class' definition. This classes value for the property will be merged on top of $class'
This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine this method as an empty function.
- Parameters:
-
-
array $properties required
The name of the properties to merge.
-
string $class required
The class to merge the property with.
-
boolean $normalize optional true
Set to true to run the properties through Set::normalize() before merging.
-
- Method defined in:
- Cake/Core/Object.php on line 187
- Return
void
_modelKey
topCreates the proper underscored model key for associations
- Parameters:
-
-
string $name required
Model class name
-
- Method defined in:
- Cake/Console/Shell.php on line 749
- Return
string Singular model key
_modelName
topCreates the proper model camelized name (singularized) for the specified name
- Parameters:
-
-
string $name required
Name
-
- Method defined in:
- Cake/Console/Shell.php on line 739
- Return
string Camelized and singularized model name
_modelNameFromKey
topCreates the proper model name from a foreign key
- Parameters:
-
-
string $key required
Foreign key
-
- Method defined in:
- Cake/Console/Shell.php on line 759
- Return
string Model name
nl
topReturns a single or multiple linefeeds sequences.
- Parameters:
-
-
integer $multiplier optional 1
Number of times the linefeed sequence should be repeated
-
- Method defined in:
- Cake/Console/Shell.php on line 585
- Return
string
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::nl
out
topOutputs a single or multiple messages to stdout. If no parameters are passed outputs just a newline.
Output levels
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.
- Parameters:
-
-
mixed $message optional NULL
A string or a an array of strings to output
-
integer $newlines optional 1
Number of newlines to append
-
integer $level optional 1
The message's output level, see above.
-
- Method defined in:
- Cake/Console/Shell.php on line 551
- Return
integer|boolean Returns the number of bytes returned from writing to stdout.
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::out
_parse
topParse tokens
- Parameters:
-
-
string $functionName required
Function name that indicates translatable string (e.g: '__')
-
array $map required
Array containing what variables it will find (e.g: domain, singular, plural)
-
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 344
- Return
void
_pluginPath
topFind the correct path for a plugin. Scans $pluginPaths for the plugin you want.
- Parameters:
-
-
string $pluginName required
Name of the plugin you want ie. DebugKit
-
- Method defined in:
- Cake/Console/Shell.php on line 809
- Return
string $path path to the correct plugin.
_pluralHumanName
topCreates the plural human name used in views
- Parameters:
-
-
string $name required
Controller name
-
- Method defined in:
- Cake/Console/Shell.php on line 799
- Return
string Plural human name
_pluralName
topCreates the plural name for views
- Parameters:
-
-
string $name required
Name to use
-
- Method defined in:
- Cake/Console/Shell.php on line 779
- Return
string Plural name for views
_processValidationRules
topProcess a validation rule for a field and looks for a message to be added to the translation map
- Parameters:
-
-
string $field required
the name of the field that is being processed
-
array $rules required
the set of validation rules for the field
-
string $file required
the file name where this validation rule was found
-
string $domain required
default domain to bind the validations to
-
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 444
- Return
void
requestAction
topCalls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.
Under the hood this method uses Router::reverse() to convert the $url parameter into a string URL. You should use URL formats that are compatible with Router::reverse()
Passing POST and GET data
POST and GET data can be simulated in requestAction. Use $extra['url'] for
GET data. The $extra['data'] parameter allows POST data simulation.
- Parameters:
-
-
mixed $url required
String or array-based url. Unlike other url arrays in CakePHP, this url will not automatically handle passed and named arguments in the $url parameter.
-
array $extra optional array ( )
if array includes the key "return" it sets the AutoRender to true. Can also be used to submit GET/POST data, and named/passed arguments.
-
- Method defined in:
- Cake/Core/Object.php on line 66
- Return
mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
runCommand
topRuns the Shell with the provided argv.
Delegates calls to Tasks and resolves methods inside the class. Commands are looked up with the following order:
- Method on the shell.
- Matching task name.
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.
- Parameters:
-
-
string $command required
The command name to run on this shell. If this argument is empty, and the shell has a
main()method, that will be called instead. -
array $argv required
Array of arguments to run the shell with. This array should be missing the shell name.
-
- Method defined in:
- Cake/Console/Shell.php on line 355
_searchFiles
topSearch files that may contain translatable strings
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 680
- Return
void
_set
topAllows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.
- Parameters:
-
-
array $properties optional array ( )
An associative array containing properties and corresponding values.
-
- Method defined in:
- Cake/Core/Object.php on line 164
- Return
void
shortPath
topMakes absolute file path easier to read
- Parameters:
-
-
string $file required
Absolute file path
-
- Method defined in:
- Cake/Console/Shell.php on line 707
- Return
string short path
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::shortPath
_singularHumanName
topCreates the singular human name used in views
- Parameters:
-
-
string $name required
Controller name
-
- Method defined in:
- Cake/Console/Shell.php on line 789
- Return
string Singular human name
_singularName
topcreates the singular name for use in views.
- Parameters:
-
-
string $name required
-
- Method defined in:
- Cake/Console/Shell.php on line 769
- Return
string $name
startup
topStarts 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.
- Method defined in:
- Cake/Console/Shell.php on line 206
_stop
topStop execution of the current script. Wraps exit() making testing easier.
- Parameters:
-
-
integer|string $status optional 0
see http://php.net/exit for values
-
- Method defined in:
- Cake/Core/Object.php on line 137
- Return
void
_store
topPrepare a file to be stored
- Parameters:
-
-
string $domain required
-
string $header required
-
string $sentence required
-
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 521
- Return
void
toString
topObject-to-string conversion. Each class can override this method as necessary.
- Method defined in:
- Cake/Core/Object.php on line 41
- Return
string The name of this class
_welcome
topwrapText
topWrap a block of text. Allows you to set the width, and indenting on a block of text.
Options
widthThe width to wrap to. Defaults to 72wordWrapOnly wrap on words breaks (spaces) Defaults to true.indentIndent the text with the string provided. Defaults to null.
- Parameters:
-
-
string $text required
Text the text to format.
-
mixed $options optional array ( )
Array of options to use, or an integer to wrap the text to.
-
- Method defined in:
- Cake/Console/Shell.php on line 530
- Return
string Wrapped / indented text
- See
- Link
- http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText
_writeFiles
topWrite the files that need to be stored
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 537
- Return
void
_writeHeader
topBuild the translation template header
- Method defined in:
- Cake/Console/Command/Task/ExtractTask.php on line 576
- Return
string Translation template header
