| @@ 40-59 (lines=20) @@ | ||
| 37 | $status = 200; |
|
| 38 | $contentType = 'text/plain'; |
|
| 39 | $output = Render::make('PlainOptionsMessage', $methods); |
|
| 40 | } else { |
|
| 41 | $status = 405; |
|
| 42 | $contentType = $this->determineContentType($request); |
|
| 43 | switch ($contentType) { |
|
| 44 | case 'application/json': |
|
| 45 | $output = Render::make('JsonNotAllowedMessage', $methods); |
|
| 46 | break; |
|
| 47 | ||
| 48 | case 'text/xml': |
|
| 49 | case 'application/xml': |
|
| 50 | $output = Render::make('XmlNotAllowedMessage', $methods); |
|
| 51 | break; |
|
| 52 | ||
| 53 | case 'text/html': |
|
| 54 | $output = Render::make('HtmlNotAllowedMessage', $methods); |
|
| 55 | break; |
|
| 56 | default: |
|
| 57 | throw new UnexpectedValueException('Cannot render unknown content type ' . $contentType); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | ||
| 61 | $body = new Body(fopen('php://temp', 'r+')); |
|
| 62 | $body->write($output); |
|
| @@ 39-58 (lines=20) @@ | ||
| 36 | if ($request->getMethod() === 'OPTIONS') { |
|
| 37 | $contentType = 'text/plain'; |
|
| 38 | $output = Render::make('PlainNotFoundOutput'); |
|
| 39 | } else { |
|
| 40 | $contentType = $this->determineContentType($request); |
|
| 41 | switch ($contentType) { |
|
| 42 | case 'application/json': |
|
| 43 | $output = Render::make('JsonNotFoundOutput'); |
|
| 44 | break; |
|
| 45 | ||
| 46 | case 'text/xml': |
|
| 47 | case 'application/xml': |
|
| 48 | $output = Render::make('XmlNotFoundOutput', $request); |
|
| 49 | break; |
|
| 50 | ||
| 51 | case 'text/html': |
|
| 52 | $output = Render::make('HtmlNotFoundOutput', $request); |
|
| 53 | break; |
|
| 54 | ||
| 55 | default: |
|
| 56 | throw new UnexpectedValueException('Cannot render unknown content type ' . $contentType); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||
| 60 | $body = new Body(fopen('php://temp', 'r+')); |
|
| 61 | $body->write($output); |
|