class ActionRequest implements RequestInterface (View source)

Represents an internal request targeted to a controller action

Properties

protected ObjectManagerInterface $objectManager
protected HashService $hashService
protected PackageManager $packageManager
protected string $controllerPackageKey

Package key of the controller which is supposed to handle this request.

protected string|null $controllerSubpackageKey

Subpackage key of the controller which is supposed to handle this request.

protected string $controllerName

Object name of the controller which is supposed to handle this request.

protected string $controllerActionName

Name of the action the controller is supposed to take.

protected array $arguments

The arguments for this request. They must be only simple types, no objects allowed.

protected array $internalArguments

Framework-internal arguments for this request, such as __referrer.

protected array $pluginArguments

Arguments and configuration for plugins – including widgets – which are sub controllers to the controller referred to by this request.

protected string $argumentNamespace

An optional namespace for arguments of this request. Used, for example, in plugins and widgets.

protected string $format

The requested representation format

protected bool $dispatched

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

protected ActionRequest $parentRequest

The parent request – either another ActionRequest or Http Request

protected ServerRequestInterface $rootRequest

Cached pointer to the root request (usually an HTTP request)

protected ActionRequest $referringRequest

Cached pointer to a request referring to this one (if any)

Methods

__construct(ActionRequest|ServerRequestInterface $parentRequest)

Constructs this action request

static ActionRequest
fromHttpRequest(ServerRequestInterface $request)

No description

createSubRequest()

Create a sub request from this action request.

ActionRequest|null
getParentRequest()

Returns the parent request

ServerRequestInterface
getHttpRequest()

Returns the top level request: the HTTP request object

getMainRequest()

Returns the top level ActionRequest: the one just below the HTTP request

bool
isMainRequest()

Checks if this request is the uppermost ActionRequest, just one below the HTTP request.

ActionRequest|null
getReferringRequest()

Returns an ActionRequest which referred to this request, if any.

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.

string
getControllerObjectName()

Returns the object name of the controller defined by the package key and controller name

void
setControllerObjectName(string $unknownCasedControllerObjectName)

Explicitly sets the object name of the controller

void
setControllerPackageKey(string $packageKey)

Sets the package key of the controller.

string
getControllerPackageKey()

Returns the package key of the specified controller.

void
setControllerSubpackageKey(string|null $subpackageKey)

Sets the subpackage key of the controller.

string|null
getControllerSubpackageKey()

Returns the subpackage key of the specified controller.

void
setControllerName(string $controllerName)

Sets the name of the controller which is supposed to handle the request.

string
getControllerName()

Returns the object name of the controller supposed to handle this request, if one was set already (if not, the name of the default controller is returned)

void
setControllerActionName(string $actionName)

Sets the name of the action contained in this request.

string
getControllerActionName()

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

void
setArgument(string $argumentName, mixed $value)

Sets the value of the specified argument

string|array
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)

void
setArguments(array $arguments)

Sets the specified arguments.

array
getArguments()

Returns an Array of arguments and their values

string|object
getInternalArgument(string $argumentName)

Returns the value of the specified internal argument.

array
getInternalArguments()

Returns the internal arguments of the request, that is, all arguments whose name starts with two underscores.

void
setArgumentNamespace(string $namespace)

Sets a namespace for the arguments of this request.

string
getArgumentNamespace()

Returns the argument namespace, if any.

array
getPluginArguments()

Returns an array of plugin argument configurations

void
setFormat(string $format)

Sets the requested representation format

string
getFormat()

Returns the requested representation format

void
emitRequestDispatched(ActionRequest $request)

Emits a signal when a Request has been dispatched

__clone()

Resets the dispatched status to false

array
__sleep()

We provide our own __sleep method, where we serialize all properties except the parentRequest if it is a HTTP request -- as this one contains $_SERVER etc.

Details

protected __construct(ActionRequest|ServerRequestInterface $parentRequest)

Constructs this action request

Parameters

ActionRequest|ServerRequestInterface $parentRequest

Either an HTTP request or another ActionRequest

Exceptions

InvalidArgumentException

static ActionRequest fromHttpRequest(ServerRequestInterface $request)

No description

Parameters

ServerRequestInterface $request

Return Value

ActionRequest

ActionRequest createSubRequest()

Create a sub request from this action request.

Return Value

ActionRequest

ActionRequest|null getParentRequest()

Returns the parent request

Return Value

ActionRequest|null

ServerRequestInterface getHttpRequest()

Returns the top level request: the HTTP request object

Return Value

ServerRequestInterface

RequestInterface getMainRequest()

Returns the top level ActionRequest: the one just below the HTTP request

Return Value

RequestInterface

bool isMainRequest()

Checks if this request is the uppermost ActionRequest, just one below the HTTP request.

Return Value

bool

ActionRequest|null getReferringRequest()

Returns an ActionRequest which referred to this request, if any.

The referring request is not set or determined automatically but must be explicitly set through the corresponding internal argument "__referrer". This mechanism is used by Flow's form and validation mechanisms.

void setDispatched(bool $flag)

Sets the dispatched flag

Parameters

bool $flag

If this request has been dispatched

Return Value

void

Exceptions

InvalidSlotException

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

string getControllerObjectName()

Returns the object name of the controller defined by the package key and controller name

Return Value

string

The controller's object name

void setControllerObjectName(string $unknownCasedControllerObjectName)

Explicitly sets the object name of the controller

Parameters

string $unknownCasedControllerObjectName

The fully qualified controller object name

Return Value

void

Exceptions

UnknownObjectException

void setControllerPackageKey(string $packageKey)

Sets the package key of the controller.

This function tries to determine the correct case for the given package key. If the Package Manager does not know the specified package, the package key cannot be verified or corrected and is stored as is.

Parameters

string $packageKey

The package key

Return Value

void

string getControllerPackageKey()

Returns the package key of the specified controller.

Return Value

string

The package key

void setControllerSubpackageKey(string|null $subpackageKey)

Sets the subpackage key of the controller.

Parameters

string|null $subpackageKey

The subpackage key.

Return Value

void

string|null getControllerSubpackageKey()

Returns the subpackage key of the specified controller.

If there is no subpackage key set, the method returns NULL.

Return Value

string|null

The subpackage key

void setControllerName(string $controllerName)

Sets the name of the controller which is supposed to handle the request.

Note: This is not the object name of the controller!

Examples: "Standard", "Account", ...

Parameters

string $controllerName

Name of the controller

Return Value

void

Exceptions

InvalidControllerNameException

string getControllerName()

Returns the object name of the controller supposed to handle this request, if one was set already (if not, the name of the default controller is returned)

Return Value

string

Name of the controller

void setControllerActionName(string $actionName)

Sets the name of the action contained in this request.

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

Parameters

string $actionName

Name of the action to execute by the controller

Return Value

void

Exceptions

InvalidActionNameException

string getControllerActionName()

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

Return Value

string

Action name

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
InvalidArgumentTypeException
InvalidControllerNameException
InvalidActionNameException

string|array getArgument(string $argumentName)

Returns the value of the specified argument

Parameters

string $argumentName

Name of the argument

Return Value

string|array

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

void setArguments(array $arguments)

Sets the specified arguments.

The arguments array will be reset therefore any arguments which existed before will be overwritten!

Parameters

array $arguments

An array of argument names and their values

Return Value

void

Exceptions

InvalidArgumentNameException
InvalidArgumentTypeException
InvalidControllerNameException
InvalidActionNameException

array getArguments()

Returns an Array of arguments and their values

Return Value

array

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

string|object getInternalArgument(string $argumentName)

Returns the value of the specified internal argument.

Internal arguments are set via setArgument(). In order to be handled as an internal argument, its name must start with two underscores.

Parameters

string $argumentName

Name of the argument, for example "__fooBar"

Return Value

string|object

Value of the argument, or NULL if not set.

array getInternalArguments()

Returns the internal arguments of the request, that is, all arguments whose name starts with two underscores.

Return Value

array

void setArgumentNamespace(string $namespace)

Sets a namespace for the arguments of this request.

This doesn't affect the actual behavior of argument handling within this classes' methods but is used in other parts of Flow and its libraries to render argument names which don't conflict with each other.

Parameters

string $namespace

Argument namespace

Return Value

void

string getArgumentNamespace()

Returns the argument namespace, if any.

Return Value

string

array getPluginArguments()

Returns an array of plugin argument configurations

Return Value

array

void setFormat(string $format)

Sets the requested representation format

Parameters

string $format

The desired format, something like "html", "xml", "png", "json" or the like. Can even be something like "rss.xml".

Return Value

void

string getFormat()

Returns the requested representation format

Return Value

string

The desired format, something like "html", "xml", "png", "json" or the like.

protected void emitRequestDispatched(ActionRequest $request)

Emits a signal when a Request has been dispatched

The action request is not proxyable, so the signal is dispatched manually here. The safeguard allows unit tests without the dispatcher dependency.

Parameters

ActionRequest $request

Return Value

void

Exceptions

InvalidSlotException

__clone()

Resets the dispatched status to false

array __sleep()

We provide our own __sleep method, where we serialize all properties except the parentRequest if it is a HTTP request -- as this one contains $_SERVER etc.

Return Value

array