abstract class AbstractController implements ControllerInterface (View source)

An abstract base class for HTTP based controllers

Properties

protected UriBuilder $uriBuilder
protected ValidatorResolver $validatorResolver
protected ActionRequest $request

The current action request directed to this controller

protected ActionResponse $response

The response which will be returned by this action controller

protected Arguments $arguments

Arguments passed to the controller

protected ControllerContext $controllerContext
protected PersistenceManagerInterface $persistenceManager
protected array $supportedMediaTypes

A list of IANA media types which are supported by this controller

protected string $negotiatedMediaType

The media type that was negotiated by this controller

Methods

initializeController(ActionRequest $request, ActionResponse $response)

Initializes the controller

getControllerContext()

Returns this controller's context.

void
addFlashMessage(string $messageBody, string $messageTitle = '', string $severity = Error\Message::SEVERITY_OK, array $messageArguments = [], int $messageCode = null)

Creates a Message object and adds it to the FlashMessageContainer.

never
forward(string $actionName, string $controllerName = null, string $packageKey = null, array $arguments = [])

Forwards the request to another action and / or controller.

void
forwardToRequest(ActionRequest $request)

Forwards the request to another action and / or controller.

never
redirect(string $actionName, string $controllerName = null, string $packageKey = null, array $arguments = [], int $delay = 0, int $statusCode = 303, string $format = null)

Redirects the request to another action and / or controller.

void
redirectToRequest(ActionRequest $request, int $delay = 0, int $statusCode = 303)

Redirects the request to another action and / or controller.

never
redirectToUri(mixed $uri, int $delay = 0, int $statusCode = 303)

Redirects to another URI

never
throwStatus(int $statusCode, string $statusMessage = null, string $content = null)

Sends the specified HTTP status immediately.

void
mapRequestArgumentsToControllerArguments()

Maps arguments delivered by the request object to the local controller arguments.

Details

protected initializeController(ActionRequest $request, ActionResponse $response)

Initializes the controller

This method should be called by the concrete processRequest() method.

Parameters

ActionRequest $request
ActionResponse $response

Exceptions

UnsupportedRequestTypeException

ControllerContext getControllerContext()

Returns this controller's context.

Note that the context is only available after processRequest() has been called.

Return Value

ControllerContext

The current controller context

void addFlashMessage(string $messageBody, string $messageTitle = '', string $severity = Error\Message::SEVERITY_OK, array $messageArguments = [], int $messageCode = null)

Creates a Message object and adds it to the FlashMessageContainer.

This method should be used to add FlashMessages rather than interacting with the container directly.

Parameters

string $messageBody

text of the FlashMessage

string $messageTitle

optional header of the FlashMessage

string $severity

severity of the FlashMessage (one of the Message::SEVERITY_* constants)

array $messageArguments

arguments to be passed to the FlashMessage

int $messageCode

Return Value

void

Exceptions

InvalidArgumentException

See also

Message

protected never forward(string $actionName, string $controllerName = null, string $packageKey = null, array $arguments = [])

Forwards the request to another action and / or controller.

Request is directly transferred to the other action / controller

Parameters

string $actionName

Name of the action to forward to

string $controllerName

Unqualified object name of the controller to forward to. If not specified, the current controller is used.

string $packageKey

Key of the package containing the controller to forward to. May also contain the sub package, concatenated with backslash (Vendor.Foo\Bar\Baz). If not specified, the current package is assumed.

array $arguments

Arguments to pass to the target action

Return Value

never

Exceptions

ForwardException

See also

redirect()

protected void forwardToRequest(ActionRequest $request)

Forwards the request to another action and / or controller.

Request is directly transfered to the other action / controller

Parameters

ActionRequest $request

The request to redirect to

Return Value

void

Exceptions

ForwardException

See also

redirectToRequest()

protected never redirect(string $actionName, string $controllerName = null, string $packageKey = null, array $arguments = [], int $delay = 0, int $statusCode = 303, string $format = null)

Redirects the request to another action and / or controller.

Redirect will be sent to the client which then performs another request to the new URI.

NOTE: This method only supports web requests and will throw an exception if used with other request types.

Parameters

string $actionName

Name of the action to forward to

string $controllerName

Unqualified object name of the controller to forward to. If not specified, the current controller is used.

string $packageKey

Key of the package containing the controller to forward to. If not specified, the current package is assumed.

array $arguments

Array of arguments for the target action

int $delay

(optional) The delay in seconds. Default is no delay.

int $statusCode

(optional) The HTTP status code for the redirect. Default is "303 See Other"

string $format

The format to use for the redirect URI

Return Value

never

Exceptions

StopActionException

See also

forward()

protected void redirectToRequest(ActionRequest $request, int $delay = 0, int $statusCode = 303)

Redirects the request to another action and / or controller.

Redirect will be sent to the client which then performs another request to the new URI.

NOTE: This method only supports web requests and will throw an exception if used with other request types.

Parameters

ActionRequest $request

The request to redirect to

int $delay

(optional) The delay in seconds. Default is no delay.

int $statusCode

(optional) The HTTP status code for the redirect. Default is "303 See Other"

Return Value

void

Exceptions

StopActionException

See also

forwardToRequest()

protected never redirectToUri(mixed $uri, int $delay = 0, int $statusCode = 303)

Redirects to another URI

Parameters

mixed $uri

Either a string representation of a URI or a \Neos\Flow\Http\Uri object

int $delay

(optional) The delay in seconds. Default is no delay.

int $statusCode

(optional) The HTTP status code for the redirect. Default is "303 See Other"

Return Value

never

Exceptions

UnsupportedRequestTypeException
StopActionException

protected never throwStatus(int $statusCode, string $statusMessage = null, string $content = null)

Sends the specified HTTP status immediately.

NOTE: This method only supports web requests and will throw an exception if used with other request types.

Parameters

int $statusCode

The HTTP status code

string $statusMessage

A custom HTTP status message

string $content

Body content which further explains the status

Return Value

never

Exceptions

StopActionException

protected void mapRequestArgumentsToControllerArguments()

Maps arguments delivered by the request object to the local controller arguments.

Return Value

void

Exceptions

RequiredArgumentMissingException