PHP Class Webmozart\Console\Api\Config\Config

Since: 1.0
Author: Bernhard Schussek ([email protected])
Afficher le fichier Open project: webmozart/console Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( ) Creates a new configuration.
addArgument ( string $name, integer $flags, string $description = null, mixed $default = null ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig Adds an argument.
addOption ( string $longName, string $shortName = null, integer $flags, string $description = null, mixed $default = null, string $valueName = '...' ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig Adds an option.
disableLenientArgsParsing ( ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig Disables lenient argument parsing.
enableLenientArgsParsing ( ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig Enables lenient argument parsing.
getArgsParser ( ) : Webmozart\Console\Api\Args\ArgsParser Returns the configured argument parser.
getArguments ( ) : Argument[] Returns the configured arguments.
getHandler ( ) : object Returns the command handler to execute when a command is run.
getHandlerMethod ( ) : string Returns the method of the command handler that should be executed when the configured command is run.
getHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet Returns the configured helper set.
getOptions ( ) : Option[] Returns the configured options.
isLenientArgsParsingEnabled ( ) : boolean Returns whether lenient argument parsing is enabled.
setArgsParser ( Webmozart\Console\Api\Args\ArgsParser $argsParser ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig Sets the used argument parser.
setHandler ( object | callback $handler ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig Sets the command handler to execute when a command is run.
setHandlerMethod ( string $handlerMethod ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig Sets the method of the command handler that should be executed when the configured command is run.
setHelperSet ( Symfony\Component\Console\Helper\HelperSet $helperSet ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig Sets the used helper set.

Méthodes protégées

Méthode Description
configure ( ) Adds the default configuration.
getDefaultArgsParser ( ) : Webmozart\Console\Api\Args\ArgsParser Returns the arguments parser to use if none is set.
getDefaultHandler ( ) : object Returns the command handler to use if none is set.
getDefaultHandlerMethod ( ) : string Returns the handler method to use if none is set.
getDefaultHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet Returns the helper set to use if none is set.
getDefaultLenientArgsParsing ( ) : boolean Returns whether the arguments parsing handles errors gracefully.

Method Details

__construct() public méthode

Creates a new configuration.
public __construct ( )

addArgument() public méthode

Read {@link Argument} for a more detailed description of console arguments.
See also: getArguments()
public addArgument ( string $name, integer $flags, string $description = null, mixed $default = null ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig
$name string The argument name.
$flags integer A bitwise combination of the flag constants in the {@link Argument} class.
$description string A one-line description of the argument.
$default mixed The default value. Must be `null` if the flags contain {@link Argument::REQUIRED}.
Résultat ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig The current instance.

addOption() public méthode

Read {@link Option} for a more detailed description of console options.
See also: getOptions()
public addOption ( string $longName, string $shortName = null, integer $flags, string $description = null, mixed $default = null, string $valueName = '...' ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig
$longName string The long option name.
$shortName string The short option name. Can be `null`.
$flags integer A bitwise combination of the flag constants in the {@link Option} class.
$description string A one-line description of the option.
$default mixed The default value. Must be `null` if the flags contain {@link Option::REQUIRED_VALUE}.
$valueName string The name of the value to be used in usage examples of the option.
Résultat ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig The current instance.

configure() protected méthode

Override this method in your own subclasses.
protected configure ( )

disableLenientArgsParsing() public méthode

When lenient argument parsing is enabled, the argument parser will not fail if the console arguments contain invalid or missing arguments. Lenient argument parsing is disabled by default.
See also: enableLenientArgsParsing()
public disableLenientArgsParsing ( ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig
Résultat ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig The current instance.

enableLenientArgsParsing() public méthode

When lenient argument parsing is enabled, the argument parser will not fail if the console arguments contain invalid or missing arguments. Lenient argument parsing is disabled by default.
See also: disableLenientArgsParsing()
public enableLenientArgsParsing ( ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig
Résultat ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig The current instance.

getArgsParser() public méthode

Returns the configured argument parser.
See also: setArgsParser()
public getArgsParser ( ) : Webmozart\Console\Api\Args\ArgsParser
Résultat Webmozart\Console\Api\Args\ArgsParser The argument parser.

getArguments() public méthode

Read {@link Argument} for a more detailed description of arguments.
See also: addArgument()
public getArguments ( ) : Argument[]
Résultat Webmozart\Console\Api\Args\Format\Argument[] The configured arguments.

getDefaultArgsParser() protected méthode

Returns the arguments parser to use if none is set.
protected getDefaultArgsParser ( ) : Webmozart\Console\Api\Args\ArgsParser
Résultat Webmozart\Console\Api\Args\ArgsParser The default args parser.

getDefaultHandler() protected méthode

Returns the command handler to use if none is set.
protected getDefaultHandler ( ) : object
Résultat object The default command handler.

getDefaultHandlerMethod() protected méthode

Returns the handler method to use if none is set.
protected getDefaultHandlerMethod ( ) : string
Résultat string The default handler method.

getDefaultHelperSet() protected méthode

Returns the helper set to use if none is set.
protected getDefaultHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet
Résultat Symfony\Component\Console\Helper\HelperSet The default helper set.

getDefaultLenientArgsParsing() protected méthode

Returns whether the arguments parsing handles errors gracefully.
protected getDefaultLenientArgsParsing ( ) : boolean
Résultat boolean The default value for lenient args parsing.

getHandler() public méthode

Returns the command handler to execute when a command is run.
See also: setHandler()
public getHandler ( ) : object
Résultat object The command handler.

getHandlerMethod() public méthode

Returns the method of the command handler that should be executed when the configured command is run.
See also: setHandlerMethod()
public getHandlerMethod ( ) : string
Résultat string The method name.

getHelperSet() public méthode

Returns the configured helper set.
See also: setHelperSet()
public getHelperSet ( ) : Symfony\Component\Console\Helper\HelperSet
Résultat Symfony\Component\Console\Helper\HelperSet The helper set.

getOptions() public méthode

Read {@link Option} for a more detailed description of console options.
See also: addOption()
public getOptions ( ) : Option[]
Résultat Webmozart\Console\Api\Args\Format\Option[] The configured options.

isLenientArgsParsingEnabled() public méthode

When lenient argument parsing is enabled, the argument parser will not fail if the console arguments contain invalid or missing arguments.
public isLenientArgsParsingEnabled ( ) : boolean
Résultat boolean Returns `true` if lenient parsing is enabled and `false` otherwise.

setArgsParser() public méthode

Sets the used argument parser.
See also: getArgsParser()
public setArgsParser ( Webmozart\Console\Api\Args\ArgsParser $argsParser ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig
$argsParser Webmozart\Console\Api\Args\ArgsParser The argument parser.
Résultat ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig The current instance.

setHandler() public méthode

You can pass: * An object with handler methods. * A callable that receives a {@link Command} and returns an object with handler methods. The name of the executed handler method can be configured with {@link setHandlerMethod()}. By default, the method handle() is executed.
See also: getHandler()
public setHandler ( object | callback $handler ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig
$handler object | callback The command handler or the callable creating a new command handler on demand.
Résultat ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig The current instance.

setHandlerMethod() public méthode

The method receives three arguments: * {@link Args} $args: The console arguments. * {@link IO} $io: The I/O. * {@link Command} $command: The executed command.
See also: getHandlerMethod()
public setHandlerMethod ( string $handlerMethod ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig
$handlerMethod string The method name.
Résultat ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig The current instance.

setHelperSet() public méthode

Sets the used helper set.
See also: getHelperSet()
public setHelperSet ( Symfony\Component\Console\Helper\HelperSet $helperSet ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig
$helperSet Symfony\Component\Console\Helper\HelperSet The helper set.
Résultat ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig The current instance.