class ConfigCommand extends Command (View source)

Constants

RETURN_CODE_ON_FAILURE

The return code we should return when an exception is thrown while running the command.

ALLOWASROOT_OPTION

The name of the CLI option that allows running CLI commands as root without confirmation.

ALLOWASROOT_ENV

The name of the environment variable that allows running CLI commands as root without confirmation.

Properties

protected InputInterface $input from Command
protected OutputStyle $output from Command
protected string $name from Command
protected $description
protected bool $hidden from Command
protected $signature
protected bool $canRunAsRoot Can this command be executed as root? If set to false, the command can be executed if one of these conditions is satisfied: - the users is not root - the --allow-as-root option is set - the C5_CLI_ALLOW_AS_ROOT environment variable is set - the console is interactive and the user explicitly confirm the operation. from Command
protected Repository $repository

Methods

__construct($name = null)

No description

from Command
void
configureUsingFluentDefinition()

Configure the console command using a fluent definition.

from Command
void
specifyParameters()

Specify the arguments and options on the command.

from Command
array
getArguments()

Get the arguments for this command

from Command
array
getOptions()

Get the options for this command

from Command
run(InputInterface $input, OutputInterface $output)

{@inheritdoc}

from Command
initialize(InputInterface $input, OutputInterface $output)

{@inheritdoc}

from Command
writeError(OutputInterface $output, Exception|Throwable $error) deprecated

Write an exception.

from Command
addEnvOption()

Add the "env" option to the command options.

from Command
$this
setCanRunAsRoot(bool $canRunAsRoot)

Allow/disallow running this command as root without confirmation.

from Command
bool|null
isRunningAsRoot()

Is the current user root?

from Command
confirmRunningAsRoot(InputInterface $input, OutputInterface $output)

No description

from Command
mixed
execute(InputInterface $input, OutputInterface $output)

This method is overridden to pipe execution to the handle method hiding input and output

from Command
int
call(string $command, array $arguments = [])

Call another console command.

from Command
int
callSilent(string $command, array $arguments = [])

Call another console command silently.

from Command
bool
hasArgument(string|int $name)

Determine if the given argument is present.

from Command
string|array
argument(string|null $key = null)

Get the value of a command argument.

from Command
array
arguments()

Get all of the arguments passed to the command.

from Command
bool
hasOption(string $name)

Determine if the given option is present.

from Command
string|array
option(string $key = null)

Get the value of a command option.

from Command
array
options()

Get all of the options passed to the command.

from Command
bool
confirm(string $question, bool $default = false)

Confirm a question with the user.

from Command
string
ask(string $question, string $default = null)

Prompt the user for input.

from Command
string
askWithCompletion(string $question, array $choices, string $default = null, null $attempts = null, null $strict = null)

Prompt the user for input with auto completion.

from Command
string
secret(string $question, bool $fallback = true)

Prompt the user for input but hide the answer from the console.

from Command
string
choice(string $question, array $choices, string $default = null, mixed $attempts = null, bool $multiple = null)

Give the user a single choice from an array of answers.

from Command
void
table(array $headers, array $rows, string $tableStyle = 'default', array $columnStyles = [])

Format input to textual table.

from Command
Application|Application
getApplication()

No description

from Command
configure()

No description

handle(Repository $config, Filesystem $filesystem)

No description

string
serialize(mixed $value)

No description

mixed
unserialize(string $value)

No description

doGetAction($repository, $item)

Complete a requested get action

doSetAction(Repository $repository, string $item)

Complete a requested set action

getRepository(Repository $config, Filesystem $filesystem)

No description

Details

__construct($name = null)

Parameters

$name

protected void configureUsingFluentDefinition()

Configure the console command using a fluent definition.

Return Value

void

protected void specifyParameters()

Specify the arguments and options on the command.

Return Value

void

protected array getArguments()

Get the arguments for this command

If $this->signature is specified, this method has no effect.

Return Value

array [[$name, $mode = null, $description = '', $default = null], ...]

protected array getOptions()

Get the options for this command

If $this->signature is specified, this method has no effect.

Return Value

array [[$name, $shortcut = null, $mode = null, $description = '', $default = null], ...]

run(InputInterface $input, OutputInterface $output)

{@inheritdoc}

Parameters

InputInterface $input
OutputInterface $output

protected initialize(InputInterface $input, OutputInterface $output)

{@inheritdoc}

Parameters

InputInterface $input
OutputInterface $output

See also

\Symfony\Component\Console\Command\Command::initialize()

protected writeError(OutputInterface $output, Exception|Throwable $error) deprecated

deprecated Use $this->output to manage your output

Write an exception.

Parameters

OutputInterface $output
Exception|Throwable $error

See also

OutputStyle::error()

protected Command addEnvOption()

Add the "env" option to the command options.

Return Value

Command

protected $this setCanRunAsRoot(bool $canRunAsRoot)

Allow/disallow running this command as root without confirmation.

Parameters

bool $canRunAsRoot if false the command can be executed if one of these conditions is satisfied: - the users is not root - the --allow-as-root option is set - the C5_CLI_ALLOW_AS_ROOT environment variable is set - the console is interactive and the user explicitly confirm the operation

Return Value

$this

protected bool|null isRunningAsRoot()

Is the current user root?

Return Value

bool|null NULL if unknown, or boolean if determined

protected confirmRunningAsRoot(InputInterface $input, OutputInterface $output)

Parameters

InputInterface $input
OutputInterface $output

Exceptions

UserMessageException

protected mixed execute(InputInterface $input, OutputInterface $output)

This method is overridden to pipe execution to the handle method hiding input and output

Parameters

InputInterface $input
OutputInterface $output

Return Value

mixed

int call(string $command, array $arguments = [])

Call another console command.

Parameters

string $command
array $arguments

Return Value

int

int callSilent(string $command, array $arguments = [])

Call another console command silently.

Parameters

string $command
array $arguments

Return Value

int

bool hasArgument(string|int $name)

Determine if the given argument is present.

Parameters

string|int $name

Return Value

bool

string|array argument(string|null $key = null)

Get the value of a command argument.

Parameters

string|null $key

Return Value

string|array

array arguments()

Get all of the arguments passed to the command.

Return Value

array

bool hasOption(string $name)

Determine if the given option is present.

Parameters

string $name

Return Value

bool

string|array option(string $key = null)

Get the value of a command option.

Parameters

string $key

Return Value

string|array

array options()

Get all of the options passed to the command.

Return Value

array

bool confirm(string $question, bool $default = false)

Confirm a question with the user.

Parameters

string $question
bool $default

Return Value

bool

string ask(string $question, string $default = null)

Prompt the user for input.

Parameters

string $question
string $default

Return Value

string

string askWithCompletion(string $question, array $choices, string $default = null, null $attempts = null, null $strict = null)

Prompt the user for input with auto completion.

Parameters

string $question
array $choices
string $default
null $attempts
null $strict

Return Value

string

string secret(string $question, bool $fallback = true)

Prompt the user for input but hide the answer from the console.

Parameters

string $question
bool $fallback

Return Value

string

string choice(string $question, array $choices, string $default = null, mixed $attempts = null, bool $multiple = null)

Give the user a single choice from an array of answers.

Parameters

string $question
array $choices
string $default
mixed $attempts
bool $multiple

Return Value

string

void table(array $headers, array $rows, string $tableStyle = 'default', array $columnStyles = [])

Format input to textual table.

Parameters

array $headers
array $rows
string $tableStyle
array $columnStyles

Return Value

void

Application|Application getApplication()

Return Value

Application|Application

protected configure()

handle(Repository $config, Filesystem $filesystem)

Parameters

Repository $config
Filesystem $filesystem

protected string serialize(mixed $value)

Parameters

mixed $value

Return Value

string

Exceptions

Exception

protected mixed unserialize(string $value)

Parameters

string $value

Return Value

mixed

Exceptions

Exception

private doGetAction($repository, $item)

Complete a requested get action

Parameters

$repository
$item

private doSetAction(Repository $repository, string $item)

Complete a requested set action

Parameters

Repository $repository
string $item

private Repository getRepository(Repository $config, Filesystem $filesystem)

Parameters

Repository $config
Filesystem $filesystem

Return Value

Repository