PHP Class Neos\Flow\Mvc\Controller\ActionController

The action specified in the given ActionRequest is dispatched to a method in the concrete controller whose name ends with "*Action". If no matching action method is found, the action specified in $errorMethodName is invoked. This controller also takes care of mapping arguments found in the ActionRequest to the corresponding method arguments of the action method. It also invokes validation for these arguments by invoking the Property Mapper. By defining media types in $supportedMediaTypes, content negotiation based on the browser's Accept header and additional routing configuration is used to determine the output format the controller should return. Depending on the action being called, a fitting view - determined by configuration - will be selected. By specifying patterns, custom view classes or an alternative controller / action to template path mapping can be defined.
Inheritance: extends AbstractController
Show file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$actionMethodName string Name of the action method
$defaultViewImplementation string
$defaultViewObjectName string The default view object to use if none of the resolved views can render a response for the current request.
$errorMethodName string Name of the special error action method which is called in case of errors
$mvcPropertyMappingConfigurationService MvcPropertyMappingConfigurationService
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
$reflectionService Neos\Flow\Reflection\ReflectionService
$settings array
$systemLogger Neos\Flow\Log\SystemLoggerInterface
$view Neos\Flow\Mvc\View\ViewInterface The current view, as resolved by resolveView()
$viewConfigurationManager Neos\Flow\Mvc\ViewConfigurationManager
$viewFormatToObjectNameMap array Example: array('html' => 'MyCompany\MyApp\MyHtmlView', 'json' => 'MyCompany\...
$viewObjectNamePattern string Pattern after which the view object name is built if no format-specific view could be resolved.

Public Methods

Method Description
getActionIgnoredValidationArguments ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
getActionMethodParameters ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array Returns a map of action method names and their parameters.
getActionValidateAnnotationData ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array Returns a map of action method names and their validation parameters.
getActionValidationGroups ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array Returns a map of action method names and their validation groups.
getPublicActionMethods ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
injectSettings ( array $settings ) : void
processRequest ( Neos\Flow\Mvc\RequestInterface $request, Neos\Flow\Mvc\ResponseInterface $response ) : void Handles a request. The result output is returned by altering the given response.

Protected Methods

Method Description
addErrorFlashMessage ( ) : void If an error occurred during this request, this adds a flash message describing the error to the flash message container.
callActionMethod ( ) : void Calls the specified action method and passes the arguments.
errorAction ( ) : string A special action which is called if the originally intended action could not be called, for example if the arguments were not valid.
forwardToReferringRequest ( ) : void If information on the request before the current request was sent, this method forwards back to the originating request. This effectively ends processing of the current request, so do not call this method before you have finished the necessary business logic!
getErrorFlashMessage ( ) : Neos\Error\Messages\Message A template method for displaying custom error flash messages, or to display no flash message at all on errors. Override this to customize the flash message in your action controller.
getFlattenedValidationErrorMessage ( ) : string Returns a string containing all validation errors separated by PHP_EOL.
getInformationNeededForInitializeActionMethodValidators ( ) : array This is a helper method purely used to make initializeActionMethodValidators() testable without mocking static methods.
handleTargetNotFoundError ( ) : void Checks if the arguments validation result contain errors of type TargetNotFoundError and throws a TargetNotFoundException if that's the case for a top-level object.
initializeAction ( ) : void Initializes the controller before invoking an action method.
initializeActionMethodArguments ( ) : void Implementation of the arguments initialization in the action controller: Automatically registers arguments of the current action
initializeActionMethodValidators ( ) : void Adds the needed validators to the Arguments:
initializeView ( Neos\Flow\Mvc\View\ViewInterface $view ) : void Initializes the view before invoking an action method.
resolveActionMethodName ( ) : string Resolves and checks the current action method name
resolveView ( ) : Neos\Flow\Mvc\View\ViewInterface Prepares a view for the current action and stores it in $this->view.
resolveViewObjectName ( ) : mixed Determines the fully qualified view object name.

Method Details

addErrorFlashMessage() protected method

If an error occurred during this request, this adds a flash message describing the error to the flash message container.
protected addErrorFlashMessage ( ) : void
return void

callActionMethod() protected method

If the action returns a string, it is appended to the content in the response object. If the action doesn't return anything and a valid view exists, the view is rendered automatically.
protected callActionMethod ( ) : void
return void

errorAction() protected method

The default implementation checks for TargetNotFoundErrors, sets a flash message, request errors and forwards back to the originating action. This is suitable for most actions dealing with form input.
protected errorAction ( ) : string
return string

forwardToReferringRequest() protected method

If information on the request before the current request was sent, this method forwards back to the originating request. This effectively ends processing of the current request, so do not call this method before you have finished the necessary business logic!
protected forwardToReferringRequest ( ) : void
return void

getActionIgnoredValidationArguments() public static method

public static getActionIgnoredValidationArguments ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
return array Array of argument names as key by action method name

getActionMethodParameters() public static method

Returns a map of action method names and their parameters.
public static getActionMethodParameters ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
return array Array of method parameters by action name

getActionValidateAnnotationData() public static method

Returns a map of action method names and their validation parameters.
public static getActionValidateAnnotationData ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
return array Array of validate annotation parameters by action method name

getActionValidationGroups() public static method

Returns a map of action method names and their validation groups.
public static getActionValidationGroups ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
return array Array of validation groups by action method name

getErrorFlashMessage() protected method

A template method for displaying custom error flash messages, or to display no flash message at all on errors. Override this to customize the flash message in your action controller.
protected getErrorFlashMessage ( ) : Neos\Error\Messages\Message
return Neos\Error\Messages\Message The flash message or FALSE if no flash message should be set

getFlattenedValidationErrorMessage() protected method

Returns a string containing all validation errors separated by PHP_EOL.

getInformationNeededForInitializeActionMethodValidators() protected method

This is a helper method purely used to make initializeActionMethodValidators() testable without mocking static methods.

getPublicActionMethods() public static method

public static getPublicActionMethods ( Neos\Flow\ObjectManagement\ObjectManagerInterface $objectManager ) : array
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
return array Array of all public action method names, indexed by method name

handleTargetNotFoundError() protected method

You can override this method (or the errorAction()) if you need a different behavior
protected handleTargetNotFoundError ( ) : void
return void

initializeAction() protected method

Override this method to solve tasks which all actions have in common.
protected initializeAction ( ) : void
return void

initializeActionMethodArguments() protected method

Don't override this method - use initializeAction() instead.
See also: initializeArguments()
protected initializeActionMethodArguments ( ) : void
return void

initializeActionMethodValidators() protected method

- Validators checking the data type from the @param annotation - Custom validators specified with validate annotations. - Model-based validators (validate annotations in the model) - Custom model validator classes
protected initializeActionMethodValidators ( ) : void
return void

initializeView() protected method

Override this method to solve assign variables common for all actions or prepare the view in another way before the action is called.
protected initializeView ( Neos\Flow\Mvc\View\ViewInterface $view ) : void
$view Neos\Flow\Mvc\View\ViewInterface The view to be initialized
return void

injectSettings() public method

public injectSettings ( array $settings ) : void
$settings array
return void

processRequest() public method

Handles a request. The result output is returned by altering the given response.
public processRequest ( Neos\Flow\Mvc\RequestInterface $request, Neos\Flow\Mvc\ResponseInterface $response ) : void
$request Neos\Flow\Mvc\RequestInterface The request object
$response Neos\Flow\Mvc\ResponseInterface The response, modified by this handler
return void

resolveActionMethodName() protected method

Resolves and checks the current action method name
protected resolveActionMethodName ( ) : string
return string Method name of the current action

resolveView() protected method

By default, this method tries to locate a view with a name matching the current action.
protected resolveView ( ) : Neos\Flow\Mvc\View\ViewInterface
return Neos\Flow\Mvc\View\ViewInterface the resolved view

resolveViewObjectName() protected method

Determines the fully qualified view object name.
protected resolveViewObjectName ( ) : mixed
return mixed The fully qualified view object name or FALSE if no matching view could be found.

Property Details

$actionMethodName protected property

Name of the action method
protected string $actionMethodName
return string

$defaultViewImplementation protected property

protected string $defaultViewImplementation
return string

$defaultViewObjectName protected property

The default view object to use if none of the resolved views can render a response for the current request.
protected string $defaultViewObjectName
return string

$errorMethodName protected property

Name of the special error action method which is called in case of errors
protected string $errorMethodName
return string

$mvcPropertyMappingConfigurationService protected property

protected MvcPropertyMappingConfigurationService,Neos\Flow\Mvc\Controller $mvcPropertyMappingConfigurationService
return MvcPropertyMappingConfigurationService

$objectManager protected property

protected ObjectManagerInterface,Neos\Flow\ObjectManagement $objectManager
return Neos\Flow\ObjectManagement\ObjectManagerInterface

$reflectionService protected property

protected ReflectionService,Neos\Flow\Reflection $reflectionService
return Neos\Flow\Reflection\ReflectionService

$settings protected property

protected array $settings
return array

$systemLogger protected property

protected SystemLoggerInterface,Neos\Flow\Log $systemLogger
return Neos\Flow\Log\SystemLoggerInterface

$view protected property

The current view, as resolved by resolveView()
protected ViewInterface,Neos\Flow\Mvc\View $view
return Neos\Flow\Mvc\View\ViewInterface

$viewConfigurationManager protected property

protected ViewConfigurationManager,Neos\Flow\Mvc $viewConfigurationManager
return Neos\Flow\Mvc\ViewConfigurationManager

$viewFormatToObjectNameMap protected property

Example: array('html' => 'MyCompany\MyApp\MyHtmlView', 'json' => 'MyCompany\...
protected array $viewFormatToObjectNameMap
return array

$viewObjectNamePattern protected property

Pattern after which the view object name is built if no format-specific view could be resolved.
protected string $viewObjectNamePattern
return string