TYPO3  7.6
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Command Class Reference
Inheritance diagram for Command:
BarBucCommand Foo1Command Foo2Command Foo3Command Foo4Command Foo5Command FoobarCommand FooCommand FooSubnamespaced1Command FooSubnamespaced2Command HelpCommand ListCommand DescriptorCommand1 DescriptorCommand2 TestCommand

Public Member Functions

 __construct ($name=null)
 
 ignoreValidationErrors ()
 
 setApplication (Application $application=null)
 
 setHelperSet (HelperSet $helperSet)
 
 getHelperSet ()
 
 getApplication ()
 
 isEnabled ()
 
 run (InputInterface $input, OutputInterface $output)
 
 setCode ($code)
 
 mergeApplicationDefinition ($mergeArgs=true)
 
 setDefinition ($definition)
 
 getDefinition ()
 
 getNativeDefinition ()
 
 addArgument ($name, $mode=null, $description= '', $default=null)
 
 addOption ($name, $shortcut=null, $mode=null, $description= '', $default=null)
 
 setName ($name)
 
 setProcessTitle ($title)
 
 getName ()
 
 setDescription ($description)
 
 getDescription ()
 
 setHelp ($help)
 
 getHelp ()
 
 getProcessedHelp ()
 
 setAliases ($aliases)
 
 getAliases ()
 
 getSynopsis ($short=false)
 
 addUsage ($usage)
 
 getUsages ()
 
 getHelper ($name)
 
 asText ()
 
 asXml ($asDom=false)
 

Protected Member Functions

 configure ()
 
 execute (InputInterface $input, OutputInterface $output)
 
 interact (InputInterface $input, OutputInterface $output)
 
 initialize (InputInterface $input, OutputInterface $output)
 

Private Member Functions

 validateName ($name)
 

Private Attributes

 $application
 
 $name
 
 $processTitle
 
 $aliases = array()
 
 $definition
 
 $help
 
 $description
 
 $ignoreValidationErrors = false
 
 $applicationDefinitionMerged = false
 
 $applicationDefinitionMergedWithArgs = false
 
 $code
 
 $synopsis = array()
 
 $usages = array()
 
 $helperSet
 

Detailed Description

Base class for all commands.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 32 of file vendor/symfony/console/Command/Command.php.

Constructor & Destructor Documentation

__construct (   $name = null)

Constructor.

Parameters
string | null$nameThe name of the command; passing null means it must be set in configure()
Exceptions
\LogicExceptionWhen the command name is empty

Definition at line 58 of file vendor/symfony/console/Command/Command.php.

References Command\$name, Command\configure(), and Command\setName().

Member Function Documentation

addArgument (   $name,
  $mode = null,
  $description = '',
  $default = null 
)

Adds an argument.

Parameters
string$nameThe argument name
int$modeThe argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
string$descriptionA description text
mixed$defaultThe default value (for InputArgument::OPTIONAL mode only)
Returns
Command The current instance

Definition at line 380 of file vendor/symfony/console/Command/Command.php.

References Command\$description, and Command\$name.

addOption (   $name,
  $shortcut = null,
  $mode = null,
  $description = '',
  $default = null 
)

Adds an option.

Parameters
string$nameThe option name
string$shortcutThe shortcut (can be null)
int$modeThe option mode: One of the InputOption::VALUE_* constants
string$descriptionA description text
mixed$defaultThe default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE)
Returns
Command The current instance

Definition at line 400 of file vendor/symfony/console/Command/Command.php.

References Command\$description, and Command\$name.

addUsage (   $usage)

Add a command usage example.

Parameters
string$usageThe usage, it'll be prefixed with the command name

Definition at line 602 of file vendor/symfony/console/Command/Command.php.

asText ( )

Returns a text representation of the command.

Returns
string A string representing the command
Deprecated:
since version 2.3, to be removed in 3.0.

Definition at line 646 of file vendor/symfony/console/Command/Command.php.

References OutputInterface\VERBOSITY_NORMAL.

asXml (   $asDom = false)

Returns an XML representation of the command.

Parameters
bool$asDomWhether to return a DOM or an XML string
Returns
string| An XML string representing the command
Deprecated:
since version 2.3, to be removed in 3.0.

Definition at line 666 of file vendor/symfony/console/Command/Command.php.

configure ( )
protected

Configures the current command.

Definition at line 148 of file vendor/symfony/console/Command/Command.php.

Referenced by Command\__construct().

execute ( InputInterface  $input,
OutputInterface  $output 
)
protected

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
InputInterface$inputAn InputInterface instance
OutputInterface$outputAn OutputInterface instance
Returns
null|int null or 0 if everything went fine, or an error code
Exceptions
\LogicExceptionWhen this abstract method is not implemented
See Also
setCode()

Definition at line 169 of file vendor/symfony/console/Command/Command.php.

Referenced by Command\run().

getAliases ( )

Returns the aliases for the command.

Returns
array An array of aliases for the command

Definition at line 574 of file vendor/symfony/console/Command/Command.php.

References Command\$aliases.

Referenced by Application\add(), MarkdownDescriptor\describeCommand(), TextDescriptor\describeCommand(), JsonDescriptor\getCommandData(), and XmlDescriptor\getCommandDocument().

getApplication ( )

Gets the application instance for this command.

Returns
Application An Application instance

Definition at line 127 of file vendor/symfony/console/Command/Command.php.

References Command\$application.

Referenced by HelpCommand\execute().

getDefinition ( )

Gets the InputDefinition attached to this Command.

Returns
InputDefinition An InputDefinition instance

Definition at line 348 of file vendor/symfony/console/Command/Command.php.

References Command\$definition.

Referenced by Application\add(), and Command\getNativeDefinition().

getDescription ( )

Returns the description for the command.

Returns
string The description for the command

Definition at line 486 of file vendor/symfony/console/Command/Command.php.

References Command\$description.

Referenced by TextDescriptor\describeApplication(), MarkdownDescriptor\describeCommand(), JsonDescriptor\getCommandData(), and XmlDescriptor\getCommandDocument().

getHelp ( )

Returns the help for the command.

Returns
string The help for the command

Definition at line 514 of file vendor/symfony/console/Command/Command.php.

References Command\$description.

Referenced by Command\getProcessedHelp().

getHelper (   $name)

Gets a helper instance by name.

Parameters
string$nameThe helper name
Returns
mixed The helper value
Exceptions
\InvalidArgumentExceptionif the helper is not defined

Definition at line 634 of file vendor/symfony/console/Command/Command.php.

References Command\$name.

getHelperSet ( )

Gets the helper set.

Returns
HelperSet A HelperSet instance

Definition at line 115 of file vendor/symfony/console/Command/Command.php.

References Command\$helperSet.

Referenced by Application\doRunCommand().

getName ( )
getNativeDefinition ( )

Gets the InputDefinition to be used to create XML and Text 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.

Returns
InputDefinition An InputDefinition instance

Definition at line 363 of file vendor/symfony/console/Command/Command.php.

References Command\getDefinition().

Referenced by MarkdownDescriptor\describeCommand(), TextDescriptor\describeCommand(), JsonDescriptor\getCommandData(), and XmlDescriptor\getCommandDocument().

getProcessedHelp ( )

Returns the processed help for the command replacing the command.name% and command.full_name% patterns with the real values dynamically.

Returns
string The processed help for the command

Definition at line 525 of file vendor/symfony/console/Command/Command.php.

References Command\$name, and Command\getHelp().

Referenced by MarkdownDescriptor\describeCommand(), TextDescriptor\describeCommand(), JsonDescriptor\getCommandData(), and XmlDescriptor\getCommandDocument().

getSynopsis (   $short = false)

Returns the synopsis for the command.

Parameters
bool$shortWhether to show the short version of the synopsis (with options folded) or not
Returns
string The synopsis

Definition at line 586 of file vendor/symfony/console/Command/Command.php.

Referenced by MarkdownDescriptor\describeCommand(), TextDescriptor\describeCommand(), JsonDescriptor\getCommandData(), XmlDescriptor\getCommandDocument(), and Command\run().

getUsages ( )
ignoreValidationErrors ( )

Ignores validation errors.

This is mainly useful for the help command.

Definition at line 78 of file vendor/symfony/console/Command/Command.php.

Referenced by HelpCommand\configure(), and Command\run().

initialize ( InputInterface  $input,
OutputInterface  $output 
)
protected

Initializes the command just after the input has been validated.

This is mainly useful when a lot of commands extends one main command where some things need to be initialized based on the input arguments and options.

Parameters
InputInterface$inputAn InputInterface instance
OutputInterface$outputAn OutputInterface instance

Definition at line 197 of file vendor/symfony/console/Command/Command.php.

Referenced by Command\run().

interact ( InputInterface  $input,
OutputInterface  $output 
)
protected

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
InputInterface$inputAn InputInterface instance
OutputInterface$outputAn OutputInterface instance

Definition at line 184 of file vendor/symfony/console/Command/Command.php.

Referenced by Command\run().

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 can not run properly under the current conditions.

Returns
bool

Definition at line 140 of file vendor/symfony/console/Command/Command.php.

Referenced by Application\add().

mergeApplicationDefinition (   $mergeArgs = true)

Merges the application definition with the command definition.

This method is not part of public API and should not be used directly.

Parameters
bool$mergeArgsWhether to merge or not the Application definition arguments to Command definition arguments

Definition at line 299 of file vendor/symfony/console/Command/Command.php.

Referenced by MarkdownDescriptor\describeCommand(), TextDescriptor\describeCommand(), JsonDescriptor\getCommandData(), XmlDescriptor\getCommandDocument(), and Command\run().

run ( InputInterface  $input,
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
InputInterface$inputAn InputInterface instance
OutputInterface$outputAn OutputInterface instance
Returns
int The command exit code
Exceptions
\Exception
See Also
setCode()
execute()

Definition at line 220 of file vendor/symfony/console/Command/Command.php.

References InputInterface\bind(), elseif, Command\execute(), Command\getSynopsis(), OutputInterface\getVerbosity(), Command\ignoreValidationErrors(), Command\initialize(), Command\interact(), InputInterface\isInteractive(), Command\mergeApplicationDefinition(), InputInterface\validate(), OutputInterface\VERBOSITY_VERY_VERBOSE, and OutputInterface\writeln().

Referenced by Application\doRunCommand().

setAliases (   $aliases)

Sets the aliases for the command.

Parameters
string[]$aliases An array of aliases for the command
Returns
Command The current instance
Exceptions
\InvalidArgumentExceptionWhen an alias is invalid

Definition at line 552 of file vendor/symfony/console/Command/Command.php.

References Command\$aliases, and Command\validateName().

setApplication ( Application  $application = null)

Sets the application instance for this command.

Parameters
Application$applicationAn Application instance

Definition at line 90 of file vendor/symfony/console/Command/Command.php.

References Command\$application, and Command\setHelperSet().

Referenced by Application\add().

setCode (   $code)

Sets the code to execute when running this command.

If this method is used, it overrides the code defined in the execute() method.

Parameters
callable$codeA callable(InputInterface $input, OutputInterface $output)
Returns
Command The current instance
Exceptions
\InvalidArgumentException
See Also
execute()

Definition at line 281 of file vendor/symfony/console/Command/Command.php.

References Command\$code.

setDefinition (   $definition)

Sets an array of argument and option instances.

Parameters
array | InputDefinition$definitionAn array of argument and option instances or a definition instance
Returns
Command The current instance

Definition at line 328 of file vendor/symfony/console/Command/Command.php.

References Command\$definition.

setDescription (   $description)

Sets the description for the command.

Parameters
string$descriptionThe description for the command
Returns
Command The current instance

Definition at line 472 of file vendor/symfony/console/Command/Command.php.

References Command\$description.

setHelp (   $help)

Sets the help for the command.

Parameters
string$helpThe help for the command
Returns
Command The current instance

Definition at line 500 of file vendor/symfony/console/Command/Command.php.

References Command\$help.

setHelperSet ( HelperSet  $helperSet)

Sets the helper set.

Parameters
HelperSet$helperSetA HelperSet instance

Definition at line 105 of file vendor/symfony/console/Command/Command.php.

References Command\$helperSet.

Referenced by Command\setApplication().

setName (   $name)

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
string$nameThe command name
Returns
Command The current instance
Exceptions
\InvalidArgumentExceptionWhen the name is invalid

Definition at line 423 of file vendor/symfony/console/Command/Command.php.

References Command\$name, and Command\validateName().

Referenced by Command\__construct(), Foo4Command\configure(), and BarBucCommand\configure().

setProcessTitle (   $title)

Sets the process title of the command.

This feature should be used only when creating a long process command, like a daemon.

PHP 5.5+ or the proctitle PECL library is required

Parameters
string$titleThe process title
Returns
Command The current instance

Definition at line 444 of file vendor/symfony/console/Command/Command.php.

validateName (   $name)
private

Validates a command name.

It must be non-empty and parts can optionally be separated by ":".

Parameters
string$name
Exceptions
\InvalidArgumentExceptionWhen the name is invalid

Definition at line 691 of file vendor/symfony/console/Command/Command.php.

References Command\$name.

Referenced by Command\setAliases(), and Command\setName().

Member Data Documentation

$aliases = array()
private
$application
private
$applicationDefinitionMerged = false
private

Definition at line 42 of file vendor/symfony/console/Command/Command.php.

$applicationDefinitionMergedWithArgs = false
private

Definition at line 43 of file vendor/symfony/console/Command/Command.php.

$code
private

Definition at line 44 of file vendor/symfony/console/Command/Command.php.

Referenced by Command\setCode().

$definition
private
$description
private
$help
private

Definition at line 39 of file vendor/symfony/console/Command/Command.php.

Referenced by Command\setHelp().

$helperSet
private
$ignoreValidationErrors = false
private

Definition at line 41 of file vendor/symfony/console/Command/Command.php.

$name
private
$processTitle
private

Definition at line 36 of file vendor/symfony/console/Command/Command.php.

$synopsis = array()
private

Definition at line 45 of file vendor/symfony/console/Command/Command.php.

$usages = array()
private

Definition at line 46 of file vendor/symfony/console/Command/Command.php.

Referenced by Command\getUsages().