| Conditions | 6 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | public function onPlainResponse(ViewEvent $event) |
||
| 29 | { |
||
| 30 | $request = $event->getRequest(); |
||
| 31 | $response = $event->getResponse(); |
||
| 32 | |||
| 33 | // No need to perform JSON-RPC serialization here |
||
| 34 | if (!$request instanceof RichJsonRpcRequest || $request->isNotification()) { |
||
| 35 | return; |
||
| 36 | } |
||
| 37 | |||
| 38 | // Response is already properly formatted |
||
| 39 | if ($response instanceof JsonRpcResponseInterface) { |
||
| 40 | return; |
||
| 41 | } |
||
| 42 | |||
| 43 | $content = $event->getResponse(); |
||
| 44 | if (!is_scalar($content) && null !== $content) { |
||
| 45 | $content = $this->normalizer->normalize($content, $request->getAttributes()->get('_context')); |
||
| 46 | } |
||
| 47 | |||
| 48 | $response = new JsonRpcResponse($request->getId(), $content); |
||
| 49 | |||
| 50 | $event->setResponse($response); |
||
| 51 | } |
||
| 52 | |||
| 54 |