PHP Class Cake\Shell\Task\ExtractTask

Inheritance: extends Cake\Console\Shell
Show file Open project: cakephp/cakephp Class Usage Examples

Protected Properties

Property Type Description
$_exclude array An array of directories to exclude.
$_extractCore boolean Holds whether this call should extract the CakePHP Lib messages
$_file string Current file being processed
$_files array Files from where to extract
$_merge boolean Merge all domain strings into the default.pot file
$_output string Destination path
$_paths array Paths to use when looking for strings
$_storage array Contains all content waiting to be write
$_tokens array Extracted tokens
$_translations array Extracted strings indexed by domain.
$_validationDomain boolean Holds the validation string domain to use for validation messages when extracting

Public Methods

Method Description
getOptionParser ( ) : Cake\Console\ConsoleOptionParser Gets the option parser instance and configures it.
main ( ) : void Execution method always used for tasks

Protected Methods

Method Description
_addTranslation ( string $domain, string $msgid, array $details = [] ) : void Add a translation to the internal translations property
_buildFiles ( ) : void Build the translate template file contents out of obtained strings
_extract ( ) : void Extract text
_extractTokens ( ) : void Extract tokens out of all files to be processed
_formatString ( string $string ) : string Format a string to be added as a translatable string
_getPaths ( ) : void Method to interact with the User and get path selections.
_getStrings ( integer &$position, integer $target ) : array Get the strings from the position forward
_isExtractingApp ( ) : boolean Returns 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.
_isPathUsable ( string $path ) : boolean Checks whether or not a given path is usable for writing.
_markerError ( string $file, integer $line, string $marker, integer $count ) : void Indicate an invalid marker on a processed file
_parse ( string $functionName, array $map ) : void Parse tokens
_searchFiles ( ) : void Search files that may contain translatable strings
_store ( string $domain, string $header, string $sentence ) : void Prepare a file to be stored
_welcome ( ) : void No welcome message.
_writeFiles ( ) : void Write the files that need to be stored
_writeHeader ( ) : string Build the translation template header

Method Details

_addTranslation() protected method

Takes care of duplicate translations
protected _addTranslation ( string $domain, string $msgid, array $details = [] ) : void
$domain string The domain
$msgid string The message string
$details array Context and plural form if any, file and line references
return void

_buildFiles() protected method

Build the translate template file contents out of obtained strings
protected _buildFiles ( ) : void
return void

_extract() protected method

Extract text
protected _extract ( ) : void
return void

_extractTokens() protected method

Extract tokens out of all files to be processed
protected _extractTokens ( ) : void
return void

_formatString() protected method

Format a string to be added as a translatable string
protected _formatString ( string $string ) : string
$string string String to format
return string Formatted string

_getPaths() protected method

Method to interact with the User and get path selections.
protected _getPaths ( ) : void
return void

_getStrings() protected method

Get the strings from the position forward
protected _getStrings ( integer &$position, integer $target ) : array
$position integer Actual position on tokens array
$target integer Number of strings to extract
return array Strings extracted

_isExtractingApp() protected method

Returns 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.
protected _isExtractingApp ( ) : boolean
return boolean

_isPathUsable() protected method

Checks whether or not a given path is usable for writing.
protected _isPathUsable ( string $path ) : boolean
$path string Path to folder
return boolean true if it exists and is writable, false otherwise

_markerError() protected method

Indicate an invalid marker on a processed file
protected _markerError ( string $file, integer $line, string $marker, integer $count ) : void
$file string File where invalid marker resides
$line integer Line number
$marker string Marker found
$count integer Count
return void

_parse() protected method

Parse tokens
protected _parse ( string $functionName, array $map ) : void
$functionName string Function name that indicates translatable string (e.g: '__')
$map array Array containing what variables it will find (e.g: domain, singular, plural)
return void

_searchFiles() protected method

Search files that may contain translatable strings
protected _searchFiles ( ) : void
return void

_store() protected method

Prepare a file to be stored
protected _store ( string $domain, string $header, string $sentence ) : void
$domain string The domain
$header string The header content.
$sentence string The sentence to store.
return void

_welcome() protected method

No welcome message.
protected _welcome ( ) : void
return void

_writeFiles() protected method

Write the files that need to be stored
protected _writeFiles ( ) : void
return void

_writeHeader() protected method

Build the translation template header
protected _writeHeader ( ) : string
return string Translation template header

getOptionParser() public method

Gets the option parser instance and configures it.
public getOptionParser ( ) : Cake\Console\ConsoleOptionParser
return Cake\Console\ConsoleOptionParser

main() public method

Execution method always used for tasks
public main ( ) : void
return void

Property Details

$_exclude protected property

An array of directories to exclude.
protected array $_exclude
return array

$_extractCore protected property

Holds whether this call should extract the CakePHP Lib messages
protected bool $_extractCore
return boolean

$_file protected property

Current file being processed
protected string $_file
return string

$_files protected property

Files from where to extract
protected array $_files
return array

$_merge protected property

Merge all domain strings into the default.pot file
protected bool $_merge
return boolean

$_output protected property

Destination path
protected string $_output
return string

$_paths protected property

Paths to use when looking for strings
protected array $_paths
return array

$_storage protected property

Contains all content waiting to be write
protected array $_storage
return array

$_tokens protected property

Extracted tokens
protected array $_tokens
return array

$_translations protected property

Extracted strings indexed by domain.
protected array $_translations
return array

$_validationDomain protected property

Holds the validation string domain to use for validation messages when extracting
protected bool $_validationDomain
return boolean