PHP 클래스 Symfony\Component\Console\Application

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

공개 메소드들

메소드 설명
__construct ( string $name = 'UNKNOWN', string $version = 'UNKNOWN' )
add ( Command $command ) : Command | null Adds a command object.
addCommands ( array $commands ) Adds an array of command objects.
all ( string $namespace = null ) : Command[] Gets the commands (registered in the given namespace if provided).
areExceptionsCaught ( ) : boolean Gets whether to catch exceptions or not during commands execution.
doRun ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer Runs the current application.
extractNamespace ( string $name, string $limit = null ) : string Returns the namespace part of the command name.
find ( string $name ) : Command Finds a command by name or alias.
findNamespace ( string $namespace ) : string Finds a registered namespace by a name or an abbreviation.
get ( string $name ) : Command Returns a registered command by name or alias.
getAbbreviations ( array $names ) : array Returns an array of possible abbreviations given a set of names.
getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition Gets the InputDefinition related to this Application.
getHelp ( ) : string Gets the help message.
getHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet Get the helper set associated with the command.
getLongVersion ( ) : string Returns the long version of the application.
getName ( ) : string Gets the name of the application.
getNamespaces ( ) : string[] Returns an array of all unique namespaces used by currently registered commands.
getTerminalDimensions ( ) : array Tries to figure out the terminal dimensions based on the current environment.
getVersion ( ) : string Gets the application version.
has ( string $name ) : boolean Returns true if the command exists, false otherwise.
isAutoExitEnabled ( ) : boolean Gets whether to automatically exit after a command execution or not.
register ( string $name ) : Command Registers a new command.
renderException ( Exception $e, Symfony\Component\Console\Output\OutputInterface $output ) Renders a caught exception.
run ( Symfony\Component\Console\Input\InputInterface $input = null, Symfony\Component\Console\Output\OutputInterface $output = null ) : integer Runs the current application.
setAutoExit ( boolean $boolean ) Sets whether to automatically exit after a command execution or not.
setCatchExceptions ( boolean $boolean ) Sets whether to catch exceptions or not during commands execution.
setDefaultCommand ( string $commandName, boolean $isSingleCommand = false ) : self Sets the default Command name.
setDefinition ( Symfony\Component\Console\Input\InputDefinition $definition ) Set an input definition to be used with this application.
setDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher )
setHelperSet ( Symfony\Component\Console\Helper\HelperSet $helperSet ) Set a helper set to be used with the command.
setName ( string $name ) Sets the application name.
setTerminalDimensions ( integer $width, integer $height ) : Application Sets terminal dimensions.
setVersion ( string $version ) Sets the application version.

보호된 메소드들

메소드 설명
configureIO ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) Configures the input and output instances based on the user arguments and options.
doRunCommand ( Command $command, Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer Runs the current command.
getCommandName ( Symfony\Component\Console\Input\InputInterface $input ) : string Gets the name of the command based on input.
getDefaultCommands ( ) : Command[] Gets the default commands that should always be available.
getDefaultHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet Gets the default helper set with the helpers that should always be available.
getDefaultInputDefinition ( ) : Symfony\Component\Console\Input\InputDefinition Gets the default input definition.
getTerminalHeight ( ) : integer | null Tries to figure out the terminal height in which this application runs.
getTerminalWidth ( ) : integer | null Tries to figure out the terminal width in which this application runs.

비공개 메소드들

메소드 설명
extractAllNamespaces ( string $name ) : string[] Returns all namespaces of the command name.
findAlternatives ( string $name, array | Traversable $collection ) : string[] Finds alternative of $name among $collection, if nothing is found in $collection, try in $abbrevs.
getAbbreviationSuggestions ( array $abbrevs ) : string Returns abbreviated suggestions in string format.
splitStringByWidth ( $string, $width )
stringWidth ( $string )

메소드 상세

__construct() 공개 메소드

public __construct ( string $name = 'UNKNOWN', string $version = 'UNKNOWN' )
$name string The name of the application
$version string The version of the application

add() 공개 메소드

If a command with the same name already exists, it will be overridden. If the command is not enabled it will not be added.
public add ( Command $command ) : Command | null
$command Symfony\Component\Console\Command\Command A Command object
리턴 Symfony\Component\Console\Command\Command | null The registered command if enabled or null

addCommands() 공개 메소드

If a Command is not enabled it will not be added.
public addCommands ( array $commands )
$commands array An array of commands

all() 공개 메소드

The array keys are the full names and the values the command instances.
public all ( string $namespace = null ) : Command[]
$namespace string A namespace name
리턴 Symfony\Component\Console\Command\Command[] An array of Command instances

areExceptionsCaught() 공개 메소드

Gets whether to catch exceptions or not during commands execution.
public areExceptionsCaught ( ) : boolean
리턴 boolean Whether to catch exceptions or not during commands execution

configureIO() 보호된 메소드

Configures the input and output instances based on the user arguments and options.
protected configureIO ( 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

doRun() 공개 메소드

Runs the current application.
public doRun ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
리턴 integer 0 if everything went fine, or an error code

doRunCommand() 보호된 메소드

If an event dispatcher has been attached to the application, events are also dispatched during the life-cycle of the command.
protected doRunCommand ( Command $command, Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer
$command Symfony\Component\Console\Command\Command A Command instance
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
리턴 integer 0 if everything went fine, or an error code

extractNamespace() 공개 메소드

This method is not part of public API and should not be used directly.
public extractNamespace ( string $name, string $limit = null ) : string
$name string The full name of the command
$limit string The maximum number of parts of the namespace
리턴 string The namespace of the command

find() 공개 메소드

Contrary to get, this command tries to find the best match if you give it an abbreviation of a name or alias.
public find ( string $name ) : Command
$name string A command name or a command alias
리턴 Symfony\Component\Console\Command\Command A Command instance

findNamespace() 공개 메소드

Finds a registered namespace by a name or an abbreviation.
public findNamespace ( string $namespace ) : string
$namespace string A namespace or abbreviation to search for
리턴 string A registered namespace

get() 공개 메소드

Returns a registered command by name or alias.
public get ( string $name ) : Command
$name string The command name or alias
리턴 Symfony\Component\Console\Command\Command A Command object

getAbbreviations() 공개 정적인 메소드

Returns an array of possible abbreviations given a set of names.
public static getAbbreviations ( array $names ) : array
$names array An array of names
리턴 array An array of abbreviations

getCommandName() 보호된 메소드

Gets the name of the command based on input.
protected getCommandName ( Symfony\Component\Console\Input\InputInterface $input ) : string
$input Symfony\Component\Console\Input\InputInterface The input interface
리턴 string The command name

getDefaultCommands() 보호된 메소드

Gets the default commands that should always be available.
protected getDefaultCommands ( ) : Command[]
리턴 Symfony\Component\Console\Command\Command[] An array of default Command instances

getDefaultHelperSet() 보호된 메소드

Gets the default helper set with the helpers that should always be available.
protected getDefaultHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet
리턴 Symfony\Component\Console\Helper\HelperSet A HelperSet instance

getDefaultInputDefinition() 보호된 메소드

Gets the default input definition.
protected getDefaultInputDefinition ( ) : Symfony\Component\Console\Input\InputDefinition
리턴 Symfony\Component\Console\Input\InputDefinition An InputDefinition instance

getDefinition() 공개 메소드

Gets the InputDefinition related to this Application.
public getDefinition ( ) : Symfony\Component\Console\Input\InputDefinition
리턴 Symfony\Component\Console\Input\InputDefinition The InputDefinition instance

getHelp() 공개 메소드

Gets the help message.
public getHelp ( ) : string
리턴 string A help message

getHelperSet() 공개 메소드

Get the helper set associated with the command.
public getHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet
리턴 Symfony\Component\Console\Helper\HelperSet The HelperSet instance associated with this command

getLongVersion() 공개 메소드

Returns the long version of the application.
public getLongVersion ( ) : string
리턴 string The long application version

getName() 공개 메소드

Gets the name of the application.
public getName ( ) : string
리턴 string The application name

getNamespaces() 공개 메소드

It does not return the global namespace which always exists.
public getNamespaces ( ) : string[]
리턴 string[] An array of namespaces

getTerminalDimensions() 공개 메소드

Tries to figure out the terminal dimensions based on the current environment.
사용 중단: since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
public getTerminalDimensions ( ) : array
리턴 array Array containing width and height

getTerminalHeight() 보호된 메소드

Tries to figure out the terminal height in which this application runs.
사용 중단: since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
protected getTerminalHeight ( ) : integer | null
리턴 integer | null

getTerminalWidth() 보호된 메소드

Tries to figure out the terminal width in which this application runs.
사용 중단: since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
protected getTerminalWidth ( ) : integer | null
리턴 integer | null

getVersion() 공개 메소드

Gets the application version.
public getVersion ( ) : string
리턴 string The application version

has() 공개 메소드

Returns true if the command exists, false otherwise.
public has ( string $name ) : boolean
$name string The command name or alias
리턴 boolean true if the command exists, false otherwise

isAutoExitEnabled() 공개 메소드

Gets whether to automatically exit after a command execution or not.
public isAutoExitEnabled ( ) : boolean
리턴 boolean Whether to automatically exit after a command execution or not

register() 공개 메소드

Registers a new command.
public register ( string $name ) : Command
$name string The command name
리턴 Symfony\Component\Console\Command\Command The newly created command

renderException() 공개 메소드

Renders a caught exception.
public renderException ( Exception $e, Symfony\Component\Console\Output\OutputInterface $output )
$e Exception An exception instance
$output Symfony\Component\Console\Output\OutputInterface An OutputInterface instance

run() 공개 메소드

Runs the current application.
public run ( Symfony\Component\Console\Input\InputInterface $input = null, Symfony\Component\Console\Output\OutputInterface $output = null ) : integer
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
리턴 integer 0 if everything went fine, or an error code

setAutoExit() 공개 메소드

Sets whether to automatically exit after a command execution or not.
public setAutoExit ( boolean $boolean )
$boolean boolean Whether to automatically exit after a command execution or not

setCatchExceptions() 공개 메소드

Sets whether to catch exceptions or not during commands execution.
public setCatchExceptions ( boolean $boolean )
$boolean boolean Whether to catch exceptions or not during commands execution

setDefaultCommand() 공개 메소드

Sets the default Command name.
public setDefaultCommand ( string $commandName, boolean $isSingleCommand = false ) : self
$commandName string The Command name
$isSingleCommand boolean Set to true if there is only one command in this application
리턴 self

setDefinition() 공개 메소드

Set an input definition to be used with this application.
public setDefinition ( Symfony\Component\Console\Input\InputDefinition $definition )
$definition Symfony\Component\Console\Input\InputDefinition The input definition

setDispatcher() 공개 메소드

public setDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher )
$dispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface

setHelperSet() 공개 메소드

Set a helper set to be used with the command.
public setHelperSet ( Symfony\Component\Console\Helper\HelperSet $helperSet )
$helperSet Symfony\Component\Console\Helper\HelperSet The helper set

setName() 공개 메소드

Sets the application name.
public setName ( string $name )
$name string The application name

setTerminalDimensions() 공개 메소드

Can be useful to force terminal dimensions for functional tests.
사용 중단: since version 3.2, to be removed in 4.0. Set the COLUMNS and LINES env vars instead.
public setTerminalDimensions ( integer $width, integer $height ) : Application
$width integer The width
$height integer The height
리턴 Application The current application

setVersion() 공개 메소드

Sets the application version.
public setVersion ( string $version )
$version string The application version