PHP Class Webmozart\Console\Api\Event\PreHandleEvent

Add a listener for this event to execute custom logic before or instead of the default handler.
Since: 1.0
Author: Bernhard Schussek ([email protected])
Inheritance: extends Symfony\Component\EventDispatcher\Event
Show file Open project: webmozart/console Class Usage Examples

Public Methods

Method Description
__construct ( Args $args, IO $io, Command $command ) Creates the event.
getArgs ( ) : Args Returns the parsed console arguments.
getCommand ( ) : Command Returns the executed command.
getIO ( ) : IO Returns the I/O.
getStatusCode ( ) : integer Returns the status code to return.
isHandled ( ) : boolean Returns whether the command was handled by the event listener.
setHandled ( boolean $handled ) Sets whether the command was handled by the event listener.
setStatusCode ( integer $statusCode ) Sets the status code to return.

Method Details

__construct() public method

Creates the event.
public __construct ( Args $args, IO $io, Command $command )
$args Webmozart\Console\Api\Args\Args The parsed console arguments.
$io Webmozart\Console\Api\IO\IO The I/O.
$command Webmozart\Console\Api\Command\Command The executed command.

getArgs() public method

Returns the parsed console arguments.
public getArgs ( ) : Args
return Webmozart\Console\Api\Args\Args The parsed console arguments.

getCommand() public method

Returns the executed command.
public getCommand ( ) : Command
return Webmozart\Console\Api\Command\Command The executed command.

getIO() public method

Returns the I/O.
public getIO ( ) : IO
return Webmozart\Console\Api\IO\IO The I/O.

getStatusCode() public method

Returns the status code to return.
public getStatusCode ( ) : integer
return integer Returns 0 on success and any positive integer on error.

isHandled() public method

Returns whether the command was handled by the event listener.
See also: setHandled()
public isHandled ( ) : boolean
return boolean Returns `true` if the command was handled and `false` otherwise.

setHandled() public method

If set to true, the handler configured for the command is not executed. Instead the status code returned by {@link getStatusCode()} is returned.
public setHandled ( boolean $handled )
$handled boolean Whether the command was handled by the event listener.

setStatusCode() public method

This method is only useful in combination with {@link setHandled()}. If the event is not marked as handled, the status code is ignored.
public setStatusCode ( integer $statusCode )
$statusCode integer Set to 0 on success and any positive integer on error.