Exemplo n.º 1
0
 /**
  * Initializes the controller
  *
  * This method should be called by the concrete processRequest() method.
  *
  * @param \TYPO3\FLOW3\Mvc\RequestInterface $request
  * @param \TYPO3\FLOW3\Mvc\ResponseInterface $response
  * @throws \TYPO3\FLOW3\Mvc\Exception\UnsupportedRequestTypeException
  */
 protected function initializeController(\TYPO3\FLOW3\Mvc\RequestInterface $request, \TYPO3\FLOW3\Mvc\ResponseInterface $response)
 {
     if (!$request instanceof ActionRequest) {
         throw new \TYPO3\FLOW3\Mvc\Exception\UnsupportedRequestTypeException(get_class($this) . ' only supports action requests – requests of type "' . get_class($request) . '" given. ', 1187701131);
     }
     $this->request = $request;
     $this->request->setDispatched(TRUE);
     $this->response = $response;
     $this->uriBuilder = new UriBuilder();
     $this->uriBuilder->setRequest($this->request);
     $this->arguments = new Arguments(array());
     $this->controllerContext = new ControllerContext($this->request, $this->response, $this->arguments, $this->uriBuilder, $this->flashMessageContainer);
     $mediaType = $request->getHttpRequest()->getNegotiatedMediaType($this->supportedMediaTypes);
     if ($mediaType === NULL) {
         $this->throwStatus(406);
     }
     if ($request->getFormat() === NULL) {
         $this->request->setFormat(MediaTypes::getFilenameExtensionFromMediaType($mediaType));
     }
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function cloneResetsTheStatusToNotDispatched()
 {
     $httpRequest = HttpRequest::create(new Uri('http://foo.com'));
     $originalRequest = new ActionRequest($httpRequest);
     $originalRequest->setDispatched(TRUE);
     $cloneRequest = clone $originalRequest;
     $this->assertTrue($originalRequest->isDispatched());
     $this->assertFalse($cloneRequest->isDispatched());
 }