/**
  * Sets temporary response to bypass view checking
  *
  * @param ViewEvent $event
  *
  * @throws \RuntimeException
  */
 public function onNullResponse(ViewEvent $event)
 {
     $request = $event->getRequest();
     if (!$request instanceof JsonRpcRequestInterface) {
         return;
     }
     // bypass view event
     if ($request->isNotification()) {
         $event->setResponse(new JsonRpcResponse());
     }
 }
 /**
  * @param ViewEvent $event
  *
  * @return SerializationContext
  * @throws \LogicException
  */
 private function createSerializerContext(ViewEvent $event)
 {
     $context = SerializationContext::create();
     $context->setSerializeNull(true);
     $attributes = $event->getRequest()->getAttributes();
     $defaults = $attributes->get('_with_default_context', true);
     if (!$defaults && false === $attributes->get('_context', false)) {
         throw new \LogicException('Could not perform object serialization as no default context allowed and no custom set');
     }
     $groups = [];
     if ($defaults) {
         $groups[] = 'Default';
     }
     if (false !== $attributes->get('_context', false)) {
         foreach ((array) $attributes->get('_context') as $group) {
             $groups[] = $group;
         }
     }
     $context->setGroups($groups);
     return $context;
 }