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
 /**
  * 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);
 }
 /**
  * @test
  */
 public function processRequestInjectsSettingsToView()
 {
     $this->actionController = $this->getAccessibleMock(ActionController::class, ['resolveActionMethodName', 'initializeActionMethodArguments', 'initializeActionMethodValidators', 'resolveView', 'callActionMethod']);
     $this->inject($this->actionController, 'objectManager', $this->mockObjectManager);
     $this->inject($this->actionController, 'controllerContext', $this->mockControllerContext);
     $mockSettings = ['foo', 'bar'];
     $this->inject($this->actionController, 'settings', $mockSettings);
     $mockMvcPropertyMappingConfigurationService = $this->createMock(Mvc\Controller\MvcPropertyMappingConfigurationService::class);
     $this->inject($this->actionController, 'mvcPropertyMappingConfigurationService', $mockMvcPropertyMappingConfigurationService);
     $mockHttpRequest = $this->getMockBuilder(Http\Request::class)->disableOriginalConstructor()->getMock();
     $mockHttpRequest->expects($this->any())->method('getNegotiatedMediaType')->will($this->returnValue('*/*'));
     $this->mockRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($mockHttpRequest));
     $mockResponse = $this->createMock(Http\Response::class);
     $mockView = $this->createMock(Mvc\View\ViewInterface::class);
     $mockView->expects($this->once())->method('assign')->with('settings', $mockSettings);
     $this->actionController->expects($this->once())->method('resolveView')->will($this->returnValue($mockView));
     $this->actionController->processRequest($this->mockRequest, $mockResponse);
 }
 /**
  * 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);
     }
 }