Chris@0: app = $app; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) { Chris@0: // Register available mime types. Chris@0: foreach ($this->formats as $format => $mime_type) { Chris@0: $request->setFormat($format, $mime_type); Chris@0: } Chris@0: Chris@0: // Determine the request format using the negotiator. Chris@16: if ($requested_format = $this->getContentType($request)) { Chris@16: $request->setRequestFormat($requested_format); Chris@16: } Chris@0: return $this->app->handle($request, $type, $catch); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Registers a format for a given MIME type. Chris@0: * Chris@0: * @param string $format Chris@0: * The format. Chris@0: * @param string $mime_type Chris@0: * The MIME type. Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function registerFormat($format, $mime_type) { Chris@0: $this->formats[$format] = $mime_type; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the normalized type of a request. Chris@0: * Chris@0: * The normalized type is a short, lowercase version of the format, such as Chris@0: * 'html', 'json' or 'atom'. Chris@0: * Chris@0: * @param \Symfony\Component\HttpFoundation\Request $request Chris@0: * The request object from which to extract the content type. Chris@0: * Chris@0: * @return string Chris@0: * The normalized type of a given request. Chris@0: */ Chris@0: protected function getContentType(Request $request) { Chris@0: // AJAX iframe uploads need special handling, because they contain a JSON Chris@0: // response wrapped in