protected function initializeController(RequestInterface $request, ResponseInterface $response)
{
if (!$request instanceof ActionRequest) {
throw new 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([]);
$this->controllerContext = new ControllerContext($this->request, $this->response, $this->arguments, $this->uriBuilder);
$mediaType = $request->getHttpRequest()->getNegotiatedMediaType($this->supportedMediaTypes);
if ($mediaType === null) {
$this->throwStatus(406);
}
if ($request->getFormat() === null) {
$this->request->setFormat(MediaTypes::getFilenameExtensionFromMediaType($mediaType));
}
}