@@ -110,6 +110,9 @@ |
||
| 110 | 110 | return $this->getStatusCodeFromThrowable($exception); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | + /** |
|
| 114 | + * @param integer $code |
|
| 115 | + */ |
|
| 113 | 116 | private function createViewFromThrowable(\Throwable $exception, $code, array $templateData): View |
| 114 | 117 | { |
| 115 | 118 | $view = new View($exception, $code, $exception instanceof HttpExceptionInterface ? $exception->getHeaders() : []); |
@@ -34,39 +34,4 @@ |
||
| 34 | 34 | $this->formatNegotiator = $formatNegotiator; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param RequestEvent $event The event |
|
| 39 | - public function onKernelRequest($event) |
|
| 40 | - { |
|
| 41 | - $request = $event->getRequest(); |
|
| 42 | - |
|
| 43 | - if (!$request->attributes->get(FOSRestBundle::ZONE_ATTRIBUTE, true)) { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - try { |
|
| 48 | - $format = $request->getRequestFormat(null); |
|
| 49 | - if (null === $format) { |
|
| 50 | - $accept = $this->formatNegotiator->getBest(''); |
|
| 51 | - if (null !== $accept && 0.0 < $accept->getQuality()) { |
|
| 52 | - $format = $request->getFormat($accept->getValue()); |
|
| 53 | - if (null !== $format) { |
|
| 54 | - $request->attributes->set('media_type', $accept->getValue()); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - if (null === $format) { |
|
| 60 | - if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { |
|
| 61 | - throw new NotAcceptableHttpException('No matching accepted Response format could be determined'); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - return; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - $request->setRequestFormat($format); |
|
| 68 | - } catch (StopFormatListenerException $e) { |
|
| 69 | - // nothing to do |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | -} |
|
| 37 | + |
|
| 73 | 38 | \ No newline at end of file |
@@ -34,39 +34,4 @@ |
||
| 34 | 34 | $this->formatNegotiator = $formatNegotiator; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param RequestEvent $event The event |
|
| 39 | - public function onKernelRequest($event) |
|
| 40 | - { |
|
| 41 | - $request = $event->getRequest(); |
|
| 42 | - |
|
| 43 | - if (!$request->attributes->get(FOSRestBundle::ZONE_ATTRIBUTE, true)) { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - try { |
|
| 48 | - $format = $request->getRequestFormat(null); |
|
| 49 | - if (null === $format) { |
|
| 50 | - $accept = $this->formatNegotiator->getBest(''); |
|
| 51 | - if (null !== $accept && 0.0 < $accept->getQuality()) { |
|
| 52 | - $format = $request->getFormat($accept->getValue()); |
|
| 53 | - if (null !== $format) { |
|
| 54 | - $request->attributes->set('media_type', $accept->getValue()); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - if (null === $format) { |
|
| 60 | - if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { |
|
| 61 | - throw new NotAcceptableHttpException('No matching accepted Response format could be determined'); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - return; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - $request->setRequestFormat($format); |
|
| 68 | - } catch (StopFormatListenerException $e) { |
|
| 69 | - // nothing to do |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | -} |
|
| 37 | + |
|
| 73 | 38 | \ No newline at end of file |