CodeIgniter v4.5 API

LocalizationFinder extends BaseCommand
in package

BaseCommand is the base class used in creating CLI commands.

Tags
see
LocalizationFinderTest

Table of Contents

Properties

$arguments  : array<string, string>
$commands  : Commands
$description  : string
$group  : string
$logger  : LoggerInterface
$name  : string
$options  : array<string, string>
$usage  : string
$arguments  : array<string, string>
the Command's Arguments description
$commands  : Commands
Instance of Commands so commands can call other commands.
$description  : string
the Command's short description
$group  : string
The group the command is lumped under when listing commands.
$logger  : LoggerInterface
The Logger to use for a command
$name  : string
The Command's name
$options  : array<string, string>
the Command's options description
$usage  : string
the Command's usage description
$languagePath  : string
$showNew  : bool
Flag for showing only translations, without saving
$verbose  : bool
Flag for output detailed information

Methods

__construct()  : mixed
__get()  : array<string, string>|Commands|LoggerInterface|string|null
Makes it simple to access our protected properties.
__isset()  : bool
Makes it simple to check our protected properties.
getPad()  : int
Get pad for $key => $value array output
run()  : int|void
Actually execute a command.
setPad()  : string
Pads our string out so that all titles are the same length to nicely line up descriptions.
showHelp()  : void
Show Help includes (Usage, Arguments, Description, Options).
call()  : int|void
Can be used by a command to run other commands.
showError()  : void
A simple method to display an error with line/file, in child commands.
arrayToTableRows()  : array<string|int, mixed>
Convert multi arrays to specific CLI table rows (flat array)
buildMultiArray()  : array<string|int, mixed>
Create multidimensional array from another keys
findLanguageKeysInFiles()  : array<string, array<string|int, mixed>|int>
findTranslationsInFile()  : array<string, array<string|int, mixed>>
isIgnoredFile()  : bool
isSubDirectory()  : bool
process()  : void
replaceArraySyntax()  : string
templateFile()  : string
writeIsVerbose()  : void
Show details in the console if the flag is set

Properties

$arguments

the Command's Arguments description

protected array<string, string> $arguments = []

$commands

Instance of Commands so commands can call other commands.

protected Commands $commands

$description

the Command's short description

protected string $description = 'Find and save available phrases to translate.'

$group

The group the command is lumped under when listing commands.

protected string $group = 'Translation'

$logger

The Logger to use for a command

protected LoggerInterface $logger

$options

the Command's options description

protected array<string, string> $options = ['--locale' => 'Specify locale (en, ru, etc.) to save files.', '--dir' => 'Directory to search for translations relative to APPPATH.', '--show-new' => 'Show only new translations in table. Does not write to files.', '--verbose' => 'Output detailed information.']

$usage

the Command's usage description

protected string $usage = 'lang:find [options]'

$showNew

Flag for showing only translations, without saving

private bool $showNew = false

Methods

__construct()

public __construct(LoggerInterface $logger, Commands $commands) : mixed
Parameters
$logger : LoggerInterface
$commands : Commands

__get()

Makes it simple to access our protected properties.

public __get(string $key) : array<string, string>|Commands|LoggerInterface|string|null
Parameters
$key : string
Return values
array<string, string>|Commands|LoggerInterface|string|null

__isset()

Makes it simple to check our protected properties.

public __isset(string $key) : bool
Parameters
$key : string
Return values
bool

getPad()

Get pad for $key => $value array output

public getPad(array<string, string> $array, int $pad) : int

Use setPad() instead.

Parameters
$array : array<string, string>
$pad : int
Tags
codeCoverageIgnore
Return values
int

run()

Actually execute a command.

public run(array<string|int, mixed> $params) : int|void
Parameters
$params : array<string|int, mixed>
Return values
int|void

setPad()

Pads our string out so that all titles are the same length to nicely line up descriptions.

public setPad(string $item, int $max[, int $extra = 2 ][, int $indent = 0 ]) : string
Parameters
$item : string
$max : int
$extra : int = 2

How many extra spaces to add at the end

$indent : int = 0
Return values
string

showHelp()

Show Help includes (Usage, Arguments, Description, Options).

public showHelp() : void

call()

Can be used by a command to run other commands.

protected call(string $command[, array<int|string, string|null> $params = [] ]) : int|void
Parameters
$command : string
$params : array<int|string, string|null> = []
Tags
throws
ReflectionException
Return values
int|void

showError()

A simple method to display an error with line/file, in child commands.

protected showError(Throwable $e) : void
Parameters
$e : Throwable

arrayToTableRows()

Convert multi arrays to specific CLI table rows (flat array)

private arrayToTableRows(string $langFileName, array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
$langFileName : string
$array : array<string|int, mixed>
Return values
array<string|int, mixed>

buildMultiArray()

Create multidimensional array from another keys

private buildMultiArray(array<string|int, mixed> $fromKeys[, string $lastArrayValue = '' ]) : array<string|int, mixed>
Parameters
$fromKeys : array<string|int, mixed>
$lastArrayValue : string = ''
Return values
array<string|int, mixed>

findLanguageKeysInFiles()

private findLanguageKeysInFiles(array<int, SplFileInfo$files) : array<string, array<string|int, mixed>|int>
Parameters
$files : array<int, SplFileInfo>
Tags
phpstan-return

array{'foundLanguageKeys': array<string, array<string, string>>, 'badLanguageKeys': array<int, array<int, string>>, 'countFiles': int}

Return values
array<string, array<string|int, mixed>|int>

findTranslationsInFile()

private findTranslationsInFile(SplFileInfo|string $file) : array<string, array<string|int, mixed>>
Parameters
$file : SplFileInfo|string
Return values
array<string, array<string|int, mixed>>

isIgnoredFile()

private isIgnoredFile(SplFileInfo $file) : bool
Parameters
$file : SplFileInfo
Return values
bool

isSubDirectory()

private isSubDirectory(string $directory, string $rootDirectory) : bool
Parameters
$directory : string
$rootDirectory : string
Return values
bool

process()

private process(string $currentDir, string $currentLocale) : void
Parameters
$currentDir : string
$currentLocale : string

replaceArraySyntax()

private replaceArraySyntax(string $code) : string
Parameters
$code : string
Return values
string

templateFile()

private templateFile([array<string|int, mixed> $language = [] ]) : string
Parameters
$language : array<string|int, mixed> = []
Return values
string

writeIsVerbose()

Show details in the console if the flag is set

private writeIsVerbose([string $text = '' ][, string|null $foreground = null ][, string|null $background = null ]) : void
Parameters
$text : string = ''
$foreground : string|null = null
$background : string|null = null

        
On this page

Search results