class Request (View source)

Represents a CLI request.

Properties

protected string $controllerObjectName
protected string $controllerCommandName
protected Command $command
protected array $arguments

The arguments for this request

protected array $exceedingArguments
protected bool $dispatched

If this request has been changed and needs to be dispatched again

Methods

void
setDispatched(bool $flag)

Sets the dispatched flag

bool
isDispatched()

If this request has been dispatched and addressed by the responsible controller and the response is ready to be sent.

void
setControllerObjectName(string $controllerObjectName)

Sets the object name of the controller

string
getControllerObjectName()

Returns the object name of the controller

getMainRequest() deprecated

Returns the this request, as CLI request nesting is not supported.

bool
isMainRequest() deprecated

Returns true, as CLI request nesting is not supported.

void
setControllerCommandName(string $commandName)

Sets the name of the command contained in this request.

string
getControllerCommandName()

Returns the name of the command the controller is supposed to execute.

getCommand()

Returns the command object for this request

void
setArgument(string $argumentName, mixed $value)

Sets the value of the specified argument

void
setArguments(array $arguments)

Sets the whole arguments array and therefore replaces any arguments which existed before.

mixed
getArgument(string $argumentName)

Returns the value of the specified argument

bool
hasArgument(string $argumentName)

Checks if an argument of the given name exists (is set)

array
getArguments()

Returns an ArrayObject of arguments and their values

void
setExceedingArguments(array $exceedingArguments)

Sets the exceeding arguments

array
getExceedingArguments()

Returns additional unnamed arguments (if any) which have been passed through the command line after all required arguments (if any) have been specified.

Details

void setDispatched(bool $flag)

Sets the dispatched flag

Parameters

bool $flag

If this request has been dispatched

Return Value

void

bool isDispatched()

If this request has been dispatched and addressed by the responsible controller and the response is ready to be sent.

The dispatcher will try to dispatch the request again if it has not been addressed yet.

Return Value

bool

true if this request has been dispatched successfully

void setControllerObjectName(string $controllerObjectName)

Sets the object name of the controller

Parameters

string $controllerObjectName

Object name of the controller which processes this request

Return Value

void

string getControllerObjectName()

Returns the object name of the controller

Return Value

string

The controller's object name

Request getMainRequest() deprecated

deprecated

Returns the this request, as CLI request nesting is not supported.

Return Value

Request

bool isMainRequest() deprecated

deprecated

Returns true, as CLI request nesting is not supported.

Return Value

bool

void setControllerCommandName(string $commandName)

Sets the name of the command contained in this request.

Note that the command name must start with a lower case letter and is case sensitive.

Parameters

string $commandName

Name of the command to execute by the controller

Return Value

void

string getControllerCommandName()

Returns the name of the command the controller is supposed to execute.

Return Value

string

Command name

Command getCommand()

Returns the command object for this request

Return Value

Command

void setArgument(string $argumentName, mixed $value)

Sets the value of the specified argument

Parameters

string $argumentName

Name of the argument to set

mixed $value

The new value

Return Value

void

Exceptions

InvalidArgumentNameException

void setArguments(array $arguments)

Sets the whole arguments array and therefore replaces any arguments which existed before.

Parameters

array $arguments

An array of argument names and their values

Return Value

void

mixed getArgument(string $argumentName)

Returns the value of the specified argument

Parameters

string $argumentName

Name of the argument

Return Value

mixed

Value of the argument

Exceptions

NoSuchArgumentException

bool hasArgument(string $argumentName)

Checks if an argument of the given name exists (is set)

Parameters

string $argumentName

Name of the argument to check

Return Value

bool

true if the argument is set, otherwise false

array getArguments()

Returns an ArrayObject of arguments and their values

Return Value

array

Array of arguments and their values (which may be arguments and values as well)

void setExceedingArguments(array $exceedingArguments)

Sets the exceeding arguments

Parameters

array $exceedingArguments

Numeric array of exceeding arguments

Return Value

void

array getExceedingArguments()

Returns additional unnamed arguments (if any) which have been passed through the command line after all required arguments (if any) have been specified.

For a command method with the signature ($argument1, $argument2) and for the command line ./flow acme:foo --argument1 Foo --argument2 Bar baz quux this method would return array(0 => 'baz', 1 => 'quux')

Return Value

array

Numeric array of exceeding argument values