Class I18nExtractCommand
Language string extractor
Property Summary
- 
        $_countMarkerError protectedintCount number of marker errors found 
- 
        $_eventClass protectedstringDefault class name for new event objects. 
- 
        $_eventManager protectedCake\Event\EventManagerInterface|nullInstance of the Cake\Event\EventManager this object is using to dispatch inner events. 
- 
        $_exclude protectedarray<string>An array of directories to exclude. 
- 
        $_extractCore protectedboolHolds whether this call should extract the CakePHP Lib messages 
- 
        $_file protectedstringCurrent file being processed 
- 
        $_files protectedarray<string>Files from where to extract 
- 
        $_markerError protectedboolDisplays marker error(s) if true 
- 
        $_merge protectedboolMerge all domain strings into the default.pot file 
- 
        $_output protectedstringDestination path 
- 
        $_paths protectedarray<string>Paths to use when looking for strings 
- 
        $_storage protectedarray<string, mixed>Contains all content waiting to be written 
- 
        $_tableLocator protectedCake\ORM\Locator\LocatorInterface|nullTable locator instance 
- 
        $_tokens protectedarrayExtracted tokens 
- 
        $_translations protectedarray<string, mixed>Extracted strings indexed by domain. 
- 
        $defaultTable protectedstring|nullThis object's default table alias. 
- 
        $name protectedstringThe name of this command. 
Method Summary
- 
          _addTranslation() protectedAdd a translation to the internal translations property 
- 
          _buildFiles() protectedBuild the translate template file contents out of obtained strings 
- 
          _extract() protectedExtract text 
- 
          _extractTokens() protectedExtract tokens out of all files to be processed 
- 
          _formatString() protectedFormat a string to be added as a translatable string 
- 
          _getPaths() protectedMethod to interact with the user and get path selections. 
- 
          _getStrings() protectedGet the strings from the position forward 
- 
          _isExtractingApp() protectedReturns 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() protectedChecks whether a given path is usable for writing. 
- 
          _markerError() protectedIndicate an invalid marker on a processed file 
- 
          _parse() protectedParse tokens 
- 
          _searchFiles() protectedSearch files that may contain translatable strings 
- 
          _store() protectedPrepare a file to be stored 
- 
          _writeFiles() protectedWrite the files that need to be stored 
- 
          _writeHeader() protectedBuild the translation template header 
- 
          abort() publicHalt the current process with a StopException. 
- 
          buildOptionParser() publicGets the option parser instance and configures it. 
- 
          checkUnchanged() protectedCheck whether the old and new output are the same, thus unchanged 
- 
          defaultName() public staticGet the command name. 
- 
          dispatchEvent() publicWrapper for creating and dispatching events. 
- 
          displayHelp() protectedOutput help content 
- 
          execute() publicExecute the command 
- 
          executeCommand() publicExecute another command with the provided set of arguments. 
- 
          fetchTable() publicConvenience method to get a table instance. 
- 
          getDescription() public staticGet the command description. 
- 
          getEventManager() publicReturns the Cake\Event\EventManager manager instance for this object. 
- 
          getName() publicGet the command name. 
- 
          getOptionParser() publicGet the option parser. 
- 
          getRootName() publicGet the root command name. 
- 
          getTableLocator() publicGets the table locator. 
- 
          initialize() publicHook method invoked by CakePHP when a command is about to be executed. 
- 
          log() publicConvenience method to write a message to Log. See Log::write() for more information on writing to logs. 
- 
          run() publicRun the command. 
- 
          setEventManager() publicReturns the Cake\Event\EventManagerInterface instance for this object. 
- 
          setName() publicSet the name this command uses in the collection. 
- 
          setOutputLevel() protectedSet the output level based on the Arguments. 
- 
          setTableLocator() publicSets the table locator. 
Method Detail
_addTranslation() ¶ protected
_addTranslation(string $domain, string $msgid, array<string, mixed> $details = []): voidAdd a translation to the internal translations property
Takes care of duplicate translations
Parameters
- 
                string$domain
- The domain 
- 
                string$msgid
- The message string 
- 
                array<string, mixed>$details optional
- Context and plural form if any, file and line references 
Returns
void_buildFiles() ¶ protected
_buildFiles(Cake\Console\Arguments $args): voidBuild the translate template file contents out of obtained strings
Parameters
- 
                Cake\Console\Arguments$args
- Console arguments 
Returns
void_extract() ¶ protected
_extract(Cake\Console\Arguments $args, Cake\Console\ConsoleIo $io): voidExtract text
Parameters
- 
                Cake\Console\Arguments$args
- The Arguments instance 
- 
                Cake\Console\ConsoleIo$io
- The io instance 
Returns
void_extractTokens() ¶ protected
_extractTokens(Cake\Console\Arguments $args, Cake\Console\ConsoleIo $io): voidExtract tokens out of all files to be processed
Parameters
- 
                Cake\Console\Arguments$args
- The io instance 
- 
                Cake\Console\ConsoleIo$io
- The io instance 
Returns
void_formatString() ¶ protected
_formatString(string $string): stringFormat a string to be added as a translatable string
Parameters
- 
                string$string
- String to format 
Returns
stringFormatted string
_getPaths() ¶ protected
_getPaths(Cake\Console\ConsoleIo $io): voidMethod to interact with the user and get path selections.
Parameters
- 
                Cake\Console\ConsoleIo$io
- The io instance. 
Returns
void_getStrings() ¶ protected
_getStrings(int $position, int $target): arrayGet the strings from the position forward
Parameters
- 
                int$position
- Actual position on tokens array 
- 
                int$target
- Number of strings to extract 
Returns
arrayStrings extracted
_isExtractingApp() ¶ protected
_isExtractingApp(): boolReturns 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.
Returns
bool_isPathUsable() ¶ protected
_isPathUsable(string $path): boolChecks whether a given path is usable for writing.
Parameters
- 
                string$path
- Path to folder 
Returns
booltrue if it exists and is writable, false otherwise
_markerError() ¶ protected
_markerError(Cake\Console\ConsoleIo $io, string $file, int $line, string $marker, int $count): voidIndicate an invalid marker on a processed file
Parameters
- 
                Cake\Console\ConsoleIo$io
- The io instance. 
- 
                string$file
- File where invalid marker resides 
- 
                int$line
- Line number 
- 
                string$marker
- Marker found 
- 
                int$count
- Count 
Returns
void_parse() ¶ protected
_parse(Cake\Console\ConsoleIo $io, string $functionName, array $map): voidParse tokens
Parameters
- 
                Cake\Console\ConsoleIo$io
- The io instance 
- 
                string$functionName
- Function name that indicates translatable string (e.g: '__') 
- 
                array$map
- Array containing what variables it will find (e.g: domain, singular, plural) 
Returns
void_searchFiles() ¶ protected
_searchFiles(): voidSearch files that may contain translatable strings
Returns
void_store() ¶ protected
_store(string $domain, string $header, string $sentence): voidPrepare a file to be stored
Parameters
- 
                string$domain
- The domain 
- 
                string$header
- The header content. 
- 
                string$sentence
- The sentence to store. 
Returns
void_writeFiles() ¶ protected
_writeFiles(Cake\Console\Arguments $args, Cake\Console\ConsoleIo $io): voidWrite the files that need to be stored
Parameters
- 
                Cake\Console\Arguments$args
- The command arguments. 
- 
                Cake\Console\ConsoleIo$io
- The console io 
Returns
void_writeHeader() ¶ protected
_writeHeader(string $domain): stringBuild the translation template header
Parameters
- 
                string$domain
- Domain 
Returns
stringTranslation template header
abort() ¶ public
abort(int $code = self::CODE_ERROR): neverHalt the current process with a StopException.
Parameters
- 
                int$code optional
- The exit code to use. 
Returns
neverThrows
Cake\Console\Exception\StopExceptionbuildOptionParser() ¶ public
buildOptionParser(Cake\Console\ConsoleOptionParser $parser): Cake\Console\ConsoleOptionParserGets the option parser instance and configures it.
Parameters
- 
                Cake\Console\ConsoleOptionParser$parser
- The parser to configure 
Returns
Cake\Console\ConsoleOptionParsercheckUnchanged() ¶ protected
checkUnchanged(string $oldFile, int $headerLength, string $newFileContent): boolCheck whether the old and new output are the same, thus unchanged
Compares the sha1 hashes of the old and new file without header.
Parameters
- 
                string$oldFile
- The existing file. 
- 
                int$headerLength
- The length of the file header in bytes. 
- 
                string$newFileContent
- The content of the new file. 
Returns
boolWhether the old and new file are unchanged.
defaultName() ¶ public static
defaultName(): stringGet the command name.
Returns the command name based on class name.
For e.g. for a command with class name UpdateTableCommand the default
name returned would be 'update_table'.
Returns
stringdispatchEvent() ¶ public
dispatchEvent(string $name, array $data = [], TSubject|null $subject = null): Cake\Event\EventInterface<TSubject>Wrapper for creating and dispatching events.
Returns a dispatched event.
Parameters
- 
                string$name
- Name of the event. 
- 
                array$data optional
- Any value you wish to be transported with this event to it can be read by listeners. 
- 
                TSubject|null$subject optional
- The object that this event applies to ($this by default). 
Returns
Cake\Event\EventInterface<TSubject>displayHelp() ¶ protected
displayHelp(Cake\Console\ConsoleOptionParser $parser, Cake\Console\Arguments $args, Cake\Console\ConsoleIo $io): voidOutput help content
Parameters
- 
                Cake\Console\ConsoleOptionParser$parser
- The option parser. 
- 
                Cake\Console\Arguments$args
- The command arguments. 
- 
                Cake\Console\ConsoleIo$io
- The console io 
Returns
voidexecute() ¶ public
execute(Cake\Console\Arguments $args, Cake\Console\ConsoleIo $io): int|nullExecute the command
Parameters
- 
                Cake\Console\Arguments$args
- The command arguments. 
- 
                Cake\Console\ConsoleIo$io
- The console io 
Returns
int|nullThe exit code or null for success
executeCommand() ¶ public
executeCommand(Cake\Console\CommandInterface|string $command, array $args = [], Cake\Console\ConsoleIo|null $io = null): int|nullExecute another command with the provided set of arguments.
If you are using a string command name, that command's dependencies will not be resolved with the application container. Instead you will need to pass the command as an object with all of its dependencies.
Parameters
- 
                Cake\Console\CommandInterface|string$command
- The command class name or command instance. 
- 
                array$args optional
- The arguments to invoke the command with. 
- 
                Cake\Console\ConsoleIo|null$io optional
- The ConsoleIo instance to use for the executed command. 
Returns
int|nullThe exit code or null for success of the command.
fetchTable() ¶ public
fetchTable(string|null $alias = null, array<string, mixed> $options = []): Cake\ORM\TableConvenience method to get a table instance.
Parameters
- 
                string|null$alias optional
- The alias name you want to get. Should be in CamelCase format. If - nullthen the value of $defaultTable property is used.
- 
                array<string, mixed>$options optional
- The options you want to build the table with. If a table has already been loaded the registry options will be ignored. 
Returns
Cake\ORM\TableThrows
Cake\Core\Exception\CakeExceptionIf `$alias` argument and `$defaultTable` property both are `null`.
See Also
getDescription() ¶ public static
getDescription(): stringGet the command description.
Returns
stringgetEventManager() ¶ public
getEventManager(): Cake\Event\EventManagerInterfaceReturns the Cake\Event\EventManager manager instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Returns
Cake\Event\EventManagerInterfacegetOptionParser() ¶ public
getOptionParser(): Cake\Console\ConsoleOptionParserGet the option parser.
You can override buildOptionParser() to define your options & arguments.
Returns
Cake\Console\ConsoleOptionParserThrows
Cake\Core\Exception\CakeExceptionWhen the parser is invalid
getTableLocator() ¶ public
getTableLocator(): Cake\ORM\Locator\LocatorInterfaceGets the table locator.
Returns
Cake\ORM\Locator\LocatorInterfaceinitialize() ¶ public
initialize(): voidHook 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.
Returns
voidlog() ¶ public
log(Stringable|string $message, string|int $level = LogLevel::ERROR, array|string $context = []): boolConvenience method to write a message to Log. See Log::write() for more information on writing to logs.
Parameters
- 
                Stringable|string$message
- Log message. 
- 
                string|int$level optional
- Error level. 
- 
                array|string$context optional
- Additional log data relevant to this message. 
Returns
boolSuccess of log write.
run() ¶ public
run(array $argv, Cake\Console\ConsoleIo $io): int|nullRun the command.
Parameters
- 
                array$argv
- 
                Cake\Console\ConsoleIo$io
Returns
int|nullsetEventManager() ¶ public
setEventManager(Cake\Event\EventManagerInterface $eventManager): $thisReturns the Cake\Event\EventManagerInterface instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Parameters
- 
                Cake\Event\EventManagerInterface$eventManager
- the eventManager to set 
Returns
$thissetName() ¶ public
setName(string $name): $thisSet 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.
Parameters
- 
                string$name
Returns
$thissetOutputLevel() ¶ protected
setOutputLevel(Cake\Console\Arguments $args, Cake\Console\ConsoleIo $io): voidSet the output level based on the Arguments.
Parameters
- 
                Cake\Console\Arguments$args
- The command arguments. 
- 
                Cake\Console\ConsoleIo$io
- The console io 
Returns
voidsetTableLocator() ¶ public
setTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $thisSets the table locator.
Parameters
- 
                Cake\ORM\Locator\LocatorInterface$tableLocator
- LocatorInterface instance. 
Returns
$thisProperty Detail
$_eventManager ¶ protected
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
Type
Cake\Event\EventManagerInterface|null