com\setasign\Konquadrat\Cli
AbstractObjectCommand Base class for all commands.
File: /Konquadrat/src/Cli/AbstractObjectCommand.php
Class hierarchy
- Symfony\Component\Console\Command\Command
Implements
- \Symfony\Component\Console\Command\SignalableCommandInterface
Summary
Methods
- __construct()
- addArgument()
- addOption()
- addUsage()
- complete()
- configure()
- execute()
- findObject()
- getAliases()
- getApplication()
- getCode()
- getCommandAttribute()
- getDefinition()
- getDescription()
- getHelp()
- getHelper()
- getHelperSet()
- getName()
- getNativeDefinition()
- getProcessedHelp()
- getSubscribedSignals()
- getSynopsis()
- getUsages()
- handleSignal()
- ignoreValidationErrors()
- initialize()
- interact()
- isEnabled()
- isHidden()
- resolveValue()
- run()
- setAliases()
- setApplication()
- setCode()
- setDefinition()
- setDescription()
- setHelp()
- setHelperSet()
- setHidden()
- setName()
- setProcessTitle()
- validateName()
Constants
FAILURE
INVALID
SUCCESS
Properties
$konquadrat
$objectFinder
$objectManager
Methods
__construct()
-
?callable $code = null
Parameters
- $name: ?string
The name of the command; passing null means it must be set in configure()
- $code: ?callable
Exceptions
Throws \Symfony\Component\Console\Exception\LogicException When the command name is empty
addArgument()
-
?int $mode = null,
array|callable(
\Symfony\Component\Console\Completion\CompletionInput , \Symfony\Component\Console\Completion\CompletionSuggestions
): \Symfony\Component\Console\Command\list<string|\Symfony\Component\Console\Completion\Suggestion> $description = '',
mixed $default = null,
array|\Closure $suggestedValues = array ( )
Adds an argument.
Parameters
- $name: string
The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
- $mode: ?int
The default value (for InputArgument::OPTIONAL mode only)
- $description: array|callable(
\Symfony\Component\Console\Completion\CompletionInput , \Symfony\Component\Console\Completion\CompletionSuggestions
): \Symfony\Component\Console\Command\list<string|\Symfony\Component\Console\Completion\Suggestion> The values used for input completion
- $default: mixed
- $suggestedValues: array|\Closure
Exceptions
Throws \Symfony\Component\Console\Exception\InvalidArgumentException When argument mode is not valid
addOption()
-
string|array|null $shortcut = null,
?int $mode = null,
array|callable(
\Symfony\Component\Console\Completion\CompletionInput , \Symfony\Component\Console\Completion\CompletionSuggestions
): \Symfony\Component\Console\Command\list<string|\Symfony\Component\Console\Completion\Suggestion> $description = '',
mixed $default = null,
array|\Closure $suggestedValues = array ( )
Adds an option.
Parameters
- $name: string
The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
- $shortcut: string|array|null
The option mode: One of the InputOption::VALUE_* constants
- $mode: ?int
The default value (must be null for InputOption::VALUE_NONE)
- $description: array|callable(
\Symfony\Component\Console\Completion\CompletionInput , \Symfony\Component\Console\Completion\CompletionSuggestions
): \Symfony\Component\Console\Command\list<string|\Symfony\Component\Console\Completion\Suggestion> The values used for input completion
- $default: mixed
- $suggestedValues: array|\Closure
Exceptions
Throws \Symfony\Component\Console\Exception\InvalidArgumentException If option mode is invalid or incompatible
addUsage()
-
Add a command usage example, it'll be prefixed with the command name.
Parameters
- $usage: string
complete()
-
\Symfony\Component\Console\Completion\CompletionSuggestions $suggestions
Supplies suggestions when resolving possible completion options for input (e.g. option or argument).
Parameters
- $input: \Symfony\Component\Console\Completion\CompletionInput
- $suggestions: \Symfony\Component\Console\Completion\CompletionSuggestions
execute()
-
\Symfony\Component\Console\Output\OutputInterface $output
Executes the current command.
This method is not abstract because you can use this class as a concrete class. In this case, instead of defining the execute() method, you set the code to execute by passing a Closure to the setCode() method.
Parameters
- $input: \Symfony\Component\Console\Input\InputInterface
- $output: \Symfony\Component\Console\Output\OutputInterface
Return Values
0 if everything went fine, or an exit code
Exceptions
Throws \Symfony\Component\Console\Exception\LogicException When this abstract method is not implemented
See
- \Symfony\Component\Console\Command\Command::setCode()
findObject()
?string $type = null
Parameters
- $value: int|string
- $type: ?string
Exceptions
Throws \com\setasign\Konquadrat\Object\UnknownObjectException
getAliases()
-
Returns the aliases for the command.
getApplication()
-
Gets the application instance for this command.
getCode()
-
Gets the code that is executed by the command.
Return Values
null if the code has not been set with setCode()
getCommandAttribute()
-
Parameters
- $code: ?callable
getDefinition()
-
Gets the InputDefinition attached to this Command.
getDescription()
-
Returns the description for the command.
getHelp()
-
Returns the help for the command.
getHelper()
-
Gets a helper instance by name.
Parameters
- $name: string
Exceptions
Throws \Symfony\Component\Console\Exception\LogicException if no HelperSet is defined
Throws \Symfony\Component\Console\Exception\InvalidArgumentException if the helper is not defined
getHelperSet()
-
Gets the helper set.
getName()
-
Returns the command name.
getNativeDefinition()
-
Gets the InputDefinition to be used to create representations of this Command.
Can be overridden to provide the original command representation when it would otherwise be changed by merging with the application InputDefinition.
This method is not part of public API and should not be used directly.
getProcessedHelp()
-
Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
getSubscribedSignals()
-
Returns the list of signals to subscribe.
See
getSynopsis()
-
Returns the synopsis for the command.
Parameters
- $short: bool
Whether to show the short version of the synopsis (with options folded) or not
getUsages()
-
Returns alternative usages of the command.
handleSignal()
-
int|false $previousExitCode = 0
The method will be called when the application is signaled.
Parameters
- $signal: int
- $previousExitCode: int|false
Return Values
The exit code to return or false to continue the normal execution
ignoreValidationErrors()
-
Ignores validation errors.
This is mainly useful for the help command.
initialize()
\Symfony\Component\Console\Output\OutputInterface $output
Parameters
- $input: \Symfony\Component\Console\Input\InputInterface
- $output: \Symfony\Component\Console\Output\OutputInterface
Exceptions
Throws \Throwable
interact()
-
\Symfony\Component\Console\Output\OutputInterface $output
Interacts with the user.
This method is executed before the InputDefinition is validated. This means that this is the only place where the command can interactively ask for values of missing required arguments.
Parameters
- $input: \Symfony\Component\Console\Input\InputInterface
- $output: \Symfony\Component\Console\Output\OutputInterface
isEnabled()
-
Checks whether the command is enabled or not in the current environment.
Override this to check for x or y and return false if the command cannot run properly under the current conditions.
isHidden()
-
Return Values
whether the command should be publicly shown or not
resolveValue()
Parameters
- $object: \com\setasign\Konquadrat\Object\AbstractObject
- $fieldName
- $value
run()
-
\Symfony\Component\Console\Output\OutputInterface $output
Runs the command.
The code to execute is either defined directly with the setCode() method or by overriding the execute() method in a sub-class.
Parameters
- $input: \Symfony\Component\Console\Input\InputInterface
- $output: \Symfony\Component\Console\Output\OutputInterface
Return Values
The command exit code
Exceptions
Throws \Symfony\Component\Console\Exception\ExceptionInterface When input binding fails. Bypass this by calling ignoreValidationErrors().
See
- \Symfony\Component\Console\Command\Command::setCode()
- \Symfony\Component\Console\Command\Command::execute()
setAliases()
-
Sets the aliases for the command.
Parameters
- $aliases: string[]
An array of aliases for the command
Exceptions
Throws \Symfony\Component\Console\Exception\InvalidArgumentException When an alias is invalid
setApplication()
-
Parameters
- $application: ?\Symfony\Component\Console\Application
setCode()
-
Sets the code to execute when running this command.
If this method is used, it overrides the code defined in the execute() method.
Parameters
- $code: callable
A callable(InputInterface $input, OutputInterface $output)
Exceptions
Throws \Symfony\Component\Console\Exception\InvalidArgumentException
See
- \Symfony\Component\Console\Command\Command::execute()
setDefinition()
-
Sets an array of argument and option instances.
Parameters
- $definition: array|\Symfony\Component\Console\Input\InputDefinition
setHelperSet()
-
Parameters
- $helperSet: \Symfony\Component\Console\Helper\HelperSet
setHidden()
-
Parameters
- $hidden: bool
Whether or not the command should be hidden from the list of commands
setName()
-
Sets the name of the command.
This method can set both the namespace and the name if you separate them by a colon (:)
$command->setName('foo:bar');
Parameters
- $name: string
Exceptions
Throws \Symfony\Component\Console\Exception\InvalidArgumentException When the name is invalid
setProcessTitle()
-
Sets the process title of the command.
This feature should be used only when creating a long process command, like a daemon.
Parameters
- $title: string
validateName()
-
Validates a command name.
It must be non-empty and parts can optionally be separated by ":".
Parameters
- $name: string
Exceptions
Throws \Symfony\Component\Console\Exception\InvalidArgumentException When the name is invalid
