PHP 클래스 Symfony\Component\Console\Command\Command

파일 보기 프로젝트 열기: symfony/symfony 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( string | null $name = null ) Constructor.
addArgument ( string $name, integer $mode = null, string $description = '', mixed $default = null ) : Command Adds an argument.
addOption ( string $name, string $shortcut = null, integer $mode = null, string $description = '', mixed $default = null ) : Command Adds an option.
addUsage ( string $usage ) : Command Add a command usage example.
getAliases ( ) : array Returns the aliases for the command.
getApplication ( ) : Application Gets the application instance for this command.
getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition Gets the InputDefinition attached to this Command.
getDescription ( ) : string Returns the description for the command.
getHelp ( ) : string Returns the help for the command.
getHelper ( string $name ) : mixed Gets a helper instance by name.
getHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet Gets the helper set.
getName ( ) : string Returns the command name.
getNativeDefinition ( ) : Symfony\Component\Console\Input\InputDefinition Gets the InputDefinition to be used to create representations of this Command.
getProcessedHelp ( ) : string Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
getSynopsis ( boolean $short = false ) : string Returns the synopsis for the command.
getUsages ( ) : array Returns alternative usages of the command.
ignoreValidationErrors ( ) Ignores validation errors.
isEnabled ( ) : boolean Checks whether the command is enabled or not in the current environment.
isHidden ( ) : boolean
mergeApplicationDefinition ( boolean $mergeArgs = true ) Merges the application definition with the command definition.
run ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer Runs the command.
setAliases ( string[] $aliases ) : Command Sets the aliases for the command.
setApplication ( Application $application = null ) Sets the application instance for this command.
setCode ( callable $code ) : Command Sets the code to execute when running this command.
setDefinition ( array | Symfony\Component\Console\Input\InputDefinition $definition ) : Command Sets an array of argument and option instances.
setDescription ( string $description ) : Command Sets the description for the command.
setHelp ( string $help ) : Command Sets the help for the command.
setHelperSet ( Symfony\Component\Console\Helper\HelperSet $helperSet ) Sets the helper set.
setHidden ( boolean $hidden ) : Command
setName ( string $name ) : Command Sets the name of the command.
setProcessTitle ( string $title ) : Command Sets the process title of the command.

보호된 메소드들

메소드 설명
configure ( ) Configures the current command.
execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : null | integer Executes the current command.
initialize ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) Initializes the command just after the input has been validated.
interact ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) Interacts with the user.

비공개 메소드들

메소드 설명
validateName ( string $name ) Validates a command name.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( string | null $name = null )
$name string | null The name of the command; passing null means it must be set in configure()

addArgument() 공개 메소드

Adds an argument.
public addArgument ( string $name, integer $mode = null, string $description = '', mixed $default = null ) : Command
$name string The argument name
$mode integer The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
$description string A description text
$default mixed The default value (for InputArgument::OPTIONAL mode only)
리턴 Command The current instance

addOption() 공개 메소드

Adds an option.
public addOption ( string $name, string $shortcut = null, integer $mode = null, string $description = '', mixed $default = null ) : Command
$name string The option name
$shortcut string The shortcut (can be null)
$mode integer The option mode: One of the InputOption::VALUE_* constants
$description string A description text
$default mixed The default value (must be null for InputOption::VALUE_NONE)
리턴 Command The current instance

addUsage() 공개 메소드

Add a command usage example.
public addUsage ( string $usage ) : Command
$usage string The usage, it'll be prefixed with the command name
리턴 Command The current instance

configure() 보호된 메소드

Configures the current command.
protected configure ( )

execute() 보호된 메소드

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.
또한 보기: setCode()
protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : null | integer
$input Symfony\Component\Console\Input\InputInterface An InputInterface instance
$output Symfony\Component\Console\Output\OutputInterface An OutputInterface instance
리턴 null | integer null or 0 if everything went fine, or an error code

getAliases() 공개 메소드

Returns the aliases for the command.
public getAliases ( ) : array
리턴 array An array of aliases for the command

getApplication() 공개 메소드

Gets the application instance for this command.
public getApplication ( ) : Application
리턴 Symfony\Component\Console\Application An Application instance

getDefinition() 공개 메소드

Gets the InputDefinition attached to this Command.
public getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition
리턴 Symfony\Component\Console\Input\InputDefinition An InputDefinition instance

getDescription() 공개 메소드

Returns the description for the command.
public getDescription ( ) : string
리턴 string The description for the command

getHelp() 공개 메소드

Returns the help for the command.
public getHelp ( ) : string
리턴 string The help for the command

getHelper() 공개 메소드

Gets a helper instance by name.
public getHelper ( string $name ) : mixed
$name string The helper name
리턴 mixed The helper value

getHelperSet() 공개 메소드

Gets the helper set.
public getHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet
리턴 Symfony\Component\Console\Helper\HelperSet A HelperSet instance

getName() 공개 메소드

Returns the command name.
public getName ( ) : string
리턴 string The command name

getNativeDefinition() 공개 메소드

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.
public getNativeDefinition ( ) : Symfony\Component\Console\Input\InputDefinition
리턴 Symfony\Component\Console\Input\InputDefinition An InputDefinition instance

getProcessedHelp() 공개 메소드

Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically.
public getProcessedHelp ( ) : string
리턴 string The processed help for the command

getSynopsis() 공개 메소드

Returns the synopsis for the command.
public getSynopsis ( boolean $short = false ) : string
$short boolean Whether to show the short version of the synopsis (with options folded) or not
리턴 string The synopsis

getUsages() 공개 메소드

Returns alternative usages of the command.
public getUsages ( ) : array
리턴 array

ignoreValidationErrors() 공개 메소드

This is mainly useful for the help command.

initialize() 보호된 메소드

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.
protected initialize ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface An InputInterface instance
$output Symfony\Component\Console\Output\OutputInterface An OutputInterface instance

interact() 보호된 메소드

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.
protected interact ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface An InputInterface instance
$output Symfony\Component\Console\Output\OutputInterface An OutputInterface instance

isEnabled() 공개 메소드

Override this to check for x or y and return false if the command can not run properly under the current conditions.
public isEnabled ( ) : boolean
리턴 boolean

isHidden() 공개 메소드

public isHidden ( ) : boolean
리턴 boolean Whether the command should be publicly shown or not.

mergeApplicationDefinition() 공개 메소드

This method is not part of public API and should not be used directly.
public mergeApplicationDefinition ( boolean $mergeArgs = true )
$mergeArgs boolean Whether to merge or not the Application definition arguments to Command definition arguments

run() 공개 메소드

The code to execute is either defined directly with the setCode() method or by overriding the execute() method in a sub-class.
또한 보기: setCode()
또한 보기: execute()
public run ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer
$input Symfony\Component\Console\Input\InputInterface An InputInterface instance
$output Symfony\Component\Console\Output\OutputInterface An OutputInterface instance
리턴 integer The command exit code

setAliases() 공개 메소드

Sets the aliases for the command.
public setAliases ( string[] $aliases ) : Command
$aliases string[] An array of aliases for the command
리턴 Command The current instance

setApplication() 공개 메소드

Sets the application instance for this command.
public setApplication ( Application $application = null )
$application Symfony\Component\Console\Application An Application instance

setCode() 공개 메소드

If this method is used, it overrides the code defined in the execute() method.
또한 보기: execute()
public setCode ( callable $code ) : Command
$code callable A callable(InputInterface $input, OutputInterface $output)
리턴 Command The current instance

setDefinition() 공개 메소드

Sets an array of argument and option instances.
public setDefinition ( array | Symfony\Component\Console\Input\InputDefinition $definition ) : Command
$definition array | Symfony\Component\Console\Input\InputDefinition An array of argument and option instances or a definition instance
리턴 Command The current instance

setDescription() 공개 메소드

Sets the description for the command.
public setDescription ( string $description ) : Command
$description string The description for the command
리턴 Command The current instance

setHelp() 공개 메소드

Sets the help for the command.
public setHelp ( string $help ) : Command
$help string The help for the command
리턴 Command The current instance

setHelperSet() 공개 메소드

Sets the helper set.
public setHelperSet ( Symfony\Component\Console\Helper\HelperSet $helperSet )
$helperSet Symfony\Component\Console\Helper\HelperSet A HelperSet instance

setHidden() 공개 메소드

public setHidden ( boolean $hidden ) : Command
$hidden boolean Whether or not the command should be hidden from the list of commands
리턴 Command The current instance

setName() 공개 메소드

This method can set both the namespace and the name if you separate them by a colon (:) $command->setName('foo:bar');
public setName ( string $name ) : Command
$name string The command name
리턴 Command The current instance

setProcessTitle() 공개 메소드

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
public setProcessTitle ( string $title ) : Command
$title string The process title
리턴 Command The current instance