PHP Class Webmozart\Console\Api\Config\ApplicationConfig

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

Méthodes publiques

Méthode Description
__construct ( string $name = null, string $version = null ) Creates a new console application.
addCommandConfig ( CommandConfig $config ) : static Adds a command configuration to the application.
addCommandConfigs ( array $configs ) : static Adds command configurations to the application.
addEventListener ( string $eventName, callable $listener, integer $priority ) : static Adds a listener for the given event name.
addEventSubscriber ( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber ) : static Adds an event subscriber to the dispatcher.
addStyle ( Style $style ) : static Adds a style to the style set.
addStyles ( array $styles ) : static Adds multiple styles to the style set.
beginCommand ( string $name ) : CommandConfig Starts a configuration block for a command.
create ( string $name = null, string $version = null ) : static Creates a new console application.
editCommand ( string $name ) : CommandConfig Alias for {@link getCommandConfig()}.
getCommandConfig ( string $name ) : CommandConfig Returns the command configuration for a given name.
getCommandConfigs ( ) : CommandConfig[] Returns all registered command configurations.
getCommandResolver ( ) : Webmozart\Console\Api\Resolver\CommandResolver Returns the used command resolver.
getDisplayName ( ) : string Returns the application name as it is displayed in the help.
getEventDispatcher ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface Returns the event dispatcher used to dispatch the console events.
getHelp ( ) : string Returns the help text of the application.
getIOFactory ( ) : callable Returns the callable used to create {@link IO} instances.
getName ( ) : string Returns the name of the application.
getStyleSet ( ) : StyleSet Returns the configured style set.
getVersion ( ) : string Returns the version of the application.
hasCommandConfig ( string $name ) : boolean Returns whether the application has a command with a given name.
hasCommandConfigs ( ) : boolean Returns whether the application has any registered command configurations.
isDebug ( ) : boolean Returns whether the application is in debug mode.
isExceptionCaught ( ) : boolean Returns whether the application catches and displays exceptions thrown while running a command.
isTerminatedAfterRun ( ) : boolean Returns whether the PHP process is terminated after running a command.
removeEventListener ( string $eventName, callable $listener ) : static Removes an event listener for the given event name.
removeEventSubscriber ( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber ) : static Removes an event subscriber from the dispatcher.
removeStyle ( string $tag ) : static Removes a style from the style set.
setCatchExceptions ( boolean $catch ) : static Sets whether the application catches and displays exceptions thrown while running a command.
setCommandConfigs ( array $configs ) : static Sets the command configurations of the application.
setCommandResolver ( Webmozart\Console\Api\Resolver\CommandResolver $commandResolver ) : static Sets the used command resolver.
setDebug ( boolean $debug ) : static Sets whether the application is in debug mode.
setDisplayName ( string $displayName ) : static Sets the application name as it is displayed in the help.
setEventDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher = null ) : static Sets the event dispatcher for dispatching the console events.
setHelp ( string $help ) : static Sets the help text of the application.
setIOFactory ( callable $ioFactory ) : static Sets the callable used to create {@link IO} instances.
setName ( string $name ) : static Sets the name of the application.
setStyleSet ( StyleSet $styleSet ) : static Sets the used style set.
setTerminateAfterRun ( boolean $terminate ) : static Sets whether to terminate the PHP process after running a command.
setVersion ( string $version ) : static Sets the version of the application.

Méthodes protégées

Méthode Description
getDefaultDisplayName ( ) : string Returns the default display name used if no display name is set.

Method Details

__construct() public méthode

Creates a new console application.
public __construct ( string $name = null, string $version = null )
$name string The name of the application.
$version string The application version.

addCommandConfig() public méthode

Adds a command configuration to the application.
See also: beginCommand()
public addCommandConfig ( CommandConfig $config ) : static
$config CommandConfig The command configuration.
Résultat static The current instance.

addCommandConfigs() public méthode

Adds command configurations to the application.
See also: beginCommand()
public addCommandConfigs ( array $configs ) : static
$configs array The command configurations.
Résultat static The current instance.

addEventListener() public méthode

See {@link ConsoleEvents} for the supported event names.
See also: EventDispatcherInterface::addListener()
public addEventListener ( string $eventName, callable $listener, integer $priority ) : static
$eventName string The event to listen to.
$listener callable The callback to execute when the event is dispatched.
$priority integer The event priority.
Résultat static The current instance.

addEventSubscriber() public méthode

Adds an event subscriber to the dispatcher.
See also: EventDispatcherInterface::addSubscriber()
public addEventSubscriber ( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber ) : static
$subscriber Symfony\Component\EventDispatcher\EventSubscriberInterface The subscriber to add.
Résultat static The current instance.

addStyle() public méthode

Adds a style to the style set.
See also: StyleSet::add()
public addStyle ( Style $style ) : static
$style Webmozart\Console\Api\Formatter\Style The style to add.
Résultat static The current instance.

addStyles() public méthode

Adds multiple styles to the style set.
See also: StyleSet::merge()
public addStyles ( array $styles ) : static
$styles array The styles to add.
Résultat static The current instance.

beginCommand() public méthode

The configuration of the command is returned by this method. You can use the fluent interface to configure the sub-command before jumping back to this configuration with {@link CommandConfig::end()}: php protected function configure() { $this ->setName('server') ->setDescription('List and manage servers') ->beginCommand('add') ->setDescription('Add a server') ->addArgument('host', Argument::REQUIRED) ->addOption('port', 'p', Option::VALUE_OPTIONAL, null, 80) ->end() ... ; }
See also: editCommand()
public beginCommand ( string $name ) : CommandConfig
$name string The name of the command.
Résultat CommandConfig The command configuration.

create() public static méthode

Creates a new console application.
public static create ( string $name = null, string $version = null ) : static
$name string The name of the application.
$version string The application version.
Résultat static The created instance.

editCommand() public méthode

This method can be used to nicely edit a command inherited from a parent configuration using the fluent API: php protected function configure() { parent::configure(); $this ->editCommand('add') ... ->end() ... ; }
See also: beginCommand()
public editCommand ( string $name ) : CommandConfig
$name string The name of the command to edit.
Résultat CommandConfig The command configuration.

getCommandConfig() public méthode

Returns the command configuration for a given name.
See also: beginCommand()
public getCommandConfig ( string $name ) : CommandConfig
$name string The name of the command.
Résultat CommandConfig The command configuration.

getCommandConfigs() public méthode

Returns all registered command configurations.
See also: beginCommand()
public getCommandConfigs ( ) : CommandConfig[]
Résultat CommandConfig[] The command configurations.

getCommandResolver() public méthode

Returns the used command resolver.
See also: setCommandResolver()
public getCommandResolver ( ) : Webmozart\Console\Api\Resolver\CommandResolver
Résultat Webmozart\Console\Api\Resolver\CommandResolver The command resolver.

getDefaultDisplayName() protected méthode

Returns the default display name used if no display name is set.
protected getDefaultDisplayName ( ) : string
Résultat string The default display name.

getDisplayName() public méthode

If no display name is set with {@link setDisplayName()}, the humanized application name is returned.
See also: setDisplayName()
public getDisplayName ( ) : string
Résultat string The display name.

getEventDispatcher() public méthode

Returns the event dispatcher used to dispatch the console events.
public getEventDispatcher ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface
Résultat Symfony\Component\EventDispatcher\EventDispatcherInterface The event dispatcher.

getHelp() public méthode

Returns the help text of the application.
public getHelp ( ) : string
Résultat string The help text.

getIOFactory() public méthode

Returns the callable used to create {@link IO} instances.
See also: setIOFactory()
public getIOFactory ( ) : callable
Résultat callable The callable or `null` if none was set.

getName() public méthode

Returns the name of the application.
See also: setName()
public getName ( ) : string
Résultat string The application name.

getStyleSet() public méthode

Returns the configured style set.
See also: setStyleSet()
public getStyleSet ( ) : StyleSet
Résultat Webmozart\Console\Api\Formatter\StyleSet The style set.

getVersion() public méthode

Returns the version of the application.
public getVersion ( ) : string
Résultat string The application version.

hasCommandConfig() public méthode

Returns whether the application has a command with a given name.
See also: beginCommand()
public hasCommandConfig ( string $name ) : boolean
$name string The name of the command.
Résultat boolean Returns `true` if the command configuration with the given name exists and `false` otherwise.

hasCommandConfigs() public méthode

Returns whether the application has any registered command configurations.
See also: beginCommand()
public hasCommandConfigs ( ) : boolean
Résultat boolean Returns `true` if command configurations were added to the application and `false` otherwise.

isDebug() public méthode

In debug mode, the verbosity is always {@link IO::DEBUG}.
See also: setDebug()
public isDebug ( ) : boolean
Résultat boolean Returns `true` if the application is in debug mode.

isExceptionCaught() public méthode

Returns whether the application catches and displays exceptions thrown while running a command.
See also: setCatchExceptions()
public isExceptionCaught ( ) : boolean
Résultat boolean Returns `true` if exceptions are caught and `false` otherwise.

isTerminatedAfterRun() public méthode

Returns whether the PHP process is terminated after running a command.
See also: setTerminateAfterRun()
public isTerminatedAfterRun ( ) : boolean
Résultat boolean Returns `true` if the PHP process is terminated after {@link run()} and `false` otherwise.

removeEventListener() public méthode

Removes an event listener for the given event name.
See also: EventDispatcherInterface::removeListener()
public removeEventListener ( string $eventName, callable $listener ) : static
$eventName string The event name.
$listener callable The callback to remove.
Résultat static The current instance.

removeEventSubscriber() public méthode

Removes an event subscriber from the dispatcher.
See also: EventDispatcherInterface::removeSubscriber()
public removeEventSubscriber ( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber ) : static
$subscriber Symfony\Component\EventDispatcher\EventSubscriberInterface The subscriber to remove.
Résultat static The current instance.

removeStyle() public méthode

Removes a style from the style set.
See also: StyleSet::remove()
public removeStyle ( string $tag ) : static
$tag string The tag of the style to remove.
Résultat static The current instance.

setCatchExceptions() public méthode

Sets whether the application catches and displays exceptions thrown while running a command.
See also: isExceptionCaught()
public setCatchExceptions ( boolean $catch ) : static
$catch boolean Whether to catch and display exceptions thrown while running a command.
Résultat static The current instance.

setCommandConfigs() public méthode

Sets the command configurations of the application.
See also: beginCommand()
public setCommandConfigs ( array $configs ) : static
$configs array The command configurations.
Résultat static The current instance.

setCommandResolver() public méthode

Sets the used command resolver.
See also: getCommandResolver()
public setCommandResolver ( Webmozart\Console\Api\Resolver\CommandResolver $commandResolver ) : static
$commandResolver Webmozart\Console\Api\Resolver\CommandResolver The command resolver.
Résultat static The current instance.

setDebug() public méthode

In debug mode, the verbosity is always {@link IO::DEBUG}.
See also: isDebug()
public setDebug ( boolean $debug ) : static
$debug boolean Set to `true` to activate the debug mode.
Résultat static The current instance.

setDisplayName() public méthode

Sets the application name as it is displayed in the help.
See also: getDisplayName()
public setDisplayName ( string $displayName ) : static
$displayName string The display name.
Résultat static The current instance.

setEventDispatcher() public méthode

Sets the event dispatcher for dispatching the console events.
public setEventDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher = null ) : static
$dispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface The event dispatcher.
Résultat static The current instance.

setHelp() public méthode

Sets the help text of the application.
public setHelp ( string $help ) : static
$help string The help text.
Résultat static The current instance.

setIOFactory() public méthode

The callable receives four arguments: * {@link RawArgs}: The raw console arguments. * {@link Input}: The input. * {@link Output}: The output. * {@link Output}: The error output. The input and output instances may be null if none were passed to {@link Application::run()}.
public setIOFactory ( callable $ioFactory ) : static
$ioFactory callable The {@link IO} factory callable.
Résultat static The current instance.

setName() public méthode

Sets the name of the application.
See also: getName()
public setName ( string $name ) : static
$name string The application name.
Résultat static The current instance.

setStyleSet() public méthode

Sets the used style set.
See also: getStyleSet()
public setStyleSet ( StyleSet $styleSet ) : static
$styleSet Webmozart\Console\Api\Formatter\StyleSet The style set to use.
Résultat static The current instance.

setTerminateAfterRun() public méthode

Sets whether to terminate the PHP process after running a command.
See also: isTerminatedAfterRun()
public setTerminateAfterRun ( boolean $terminate ) : static
$terminate boolean Whether to terminate the PHP process after running a command.
Résultat static The current instance.

setVersion() public méthode

Sets the version of the application.
public setVersion ( string $version ) : static
$version string The application version.
Résultat static The current instance.