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
 /**
  * Handles a request. The result output is returned by altering the given response.
  *
  * @param RequestInterface $request The request object
  * @param ResponseInterface $response The response, modified by this handler
  * @return void
  * @throws WidgetContextNotFoundException
  * @api
  */
 public function processRequest(RequestInterface $request, ResponseInterface $response)
 {
     /** @var $request \Neos\Flow\Mvc\ActionRequest */
     /** @var $widgetContext WidgetContext */
     $widgetContext = $request->getInternalArgument('__widgetContext');
     if ($widgetContext === null) {
         throw new WidgetContextNotFoundException('The widget context could not be found in the request.', 1307450180);
     }
     $this->widgetConfiguration = $widgetContext->getWidgetConfiguration();
     parent::processRequest($request, $response);
 }
 /**
  * Catch exceptions while processing an exception and respond to JSON format
  * TODO: This is an explicit exception handling that will be replaced by format-enabled exception handlers.
  *
  * @param RequestInterface $request The request object
  * @param ResponseInterface $response The response, modified by this handler
  * @return void
  * @throws \Exception
  */
 public function processRequest(RequestInterface $request, ResponseInterface $response)
 {
     try {
         parent::processRequest($request, $response);
     } catch (StopActionException $exception) {
         throw $exception;
     } catch (\Exception $exception) {
         if ($this->request->getFormat() !== 'json' || !$response instanceof HttpResponse) {
             throw $exception;
         }
         $exceptionData = $this->convertException($exception);
         $response->setHeader('Content-Type', 'application/json');
         if ($exception instanceof FlowException) {
             $response->setStatus($exception->getStatusCode());
         } else {
             $response->setStatus(500);
         }
         $response->setContent(json_encode(array('error' => $exceptionData)));
         $this->systemLogger->logException($exception);
     }
 }
 /**
  * @test
  * @dataProvider ignoredValidationArgumentsProvider
  */
 public function initializeActionMethodValidatorsDoesNotAddValidatorForIgnoredArgumentsWithoutEvaluation($evaluateIgnoredValidationArgument, $setValidatorShouldBeCalled)
 {
     $this->actionController = $this->getAccessibleMock(ActionController::class, ['getInformationNeededForInitializeActionMethodValidators']);
     $mockArgument = $this->getMockBuilder(Mvc\Controller\Argument::class)->disableOriginalConstructor()->getMock();
     $mockArgument->expects($this->any())->method('getName')->will($this->returnValue('node'));
     $arguments = new Arguments();
     $arguments['node'] = $mockArgument;
     $ignoredValidationArguments = ['showAction' => ['node' => ['evaluate' => $evaluateIgnoredValidationArgument]]];
     $mockValidator = $this->createMock(ValidatorInterface::class);
     $parameterValidators = ['node' => $mockValidator];
     $this->actionController->expects($this->any())->method('getInformationNeededForInitializeActionMethodValidators')->will($this->returnValue([[], [], [], $ignoredValidationArguments]));
     $this->inject($this->actionController, 'actionMethodName', 'showAction');
     $this->inject($this->actionController, 'arguments', $arguments);
     $this->inject($this->actionController, 'objectManager', $this->mockObjectManager);
     $mockValidatorResolver = $this->createMock(ValidatorResolver::class);
     $mockValidatorResolver->expects($this->any())->method('buildMethodArgumentsValidatorConjunctions')->will($this->returnValue($parameterValidators));
     $this->inject($this->actionController, 'validatorResolver', $mockValidatorResolver);
     if ($setValidatorShouldBeCalled) {
         $mockArgument->expects($this->once())->method('setValidator');
     } else {
         $mockArgument->expects($this->never())->method('setValidator');
     }
     $this->actionController->_call('initializeActionMethodValidators');
 }
 /**
  * @param ViewInterface $view
  * @return void
  */
 protected function initializeView(ViewInterface $view)
 {
     /** @var TemplateView $view */
     $view->setOption('templateRootPathPattern', '@packageResourcesPath/Private/');
     parent::initializeView($view);
 }
 /**
  * Redirects the web request to another uri.
  *
  * NOTE: This method only supports web requests and will throw an exception
  * if used with other request types.
  *
  * @param mixed $uri Either a string representation of a URI or a \Neos\Flow\Http\Uri object
  * @param integer $delay (optional) The delay in seconds. Default is no delay.
  * @param integer $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other"
  * @return void
  * @throws StopActionException
  * @api
  */
 protected function redirectToUri($uri, $delay = 0, $statusCode = 303)
 {
     // the parent method throws the exception, but we need to act afterwards
     // thus the code in catch - it's the expected state
     try {
         parent::redirectToUri($uri, $delay, $statusCode);
     } catch (StopActionException $exception) {
         if ($this->request->getFormat() === 'json') {
             $this->response->setContent('');
         }
         throw $exception;
     }
 }
 /**
  * Add a translated flashMessage.
  *
  * @param string $messageBody The translation id for the message body.
  * @param string $messageTitle The translation id for the message title.
  * @param string $severity
  * @param array $messageArguments
  * @param integer $messageCode
  * @return void
  */
 public function addFlashMessage($messageBody, $messageTitle = '', $severity = Message::SEVERITY_OK, array $messageArguments = array(), $messageCode = null)
 {
     if (is_string($messageBody)) {
         $messageBody = $this->translator->translateById($messageBody, $messageArguments, null, null, 'Main', 'Neos.Media') ?: $messageBody;
     }
     $messageTitle = $this->translator->translateById($messageTitle, $messageArguments, null, null, 'Main', 'Neos.Media');
     parent::addFlashMessage($messageBody, $messageTitle, $severity, $messageArguments, $messageCode);
 }