/**
  * Get correct response for validation failed exception
  *
  * @param GetResponseForExceptionEvent $event           event
  * @param EventDispatcherInterface     $eventDispatcher eventDispatcher
  * @param ValidationFailedException    $exception       exception
  *
  * @return Response|null
  */
 private function getValidationFailedExceptionResponse(GetResponseForExceptionEvent $event, EventDispatcherInterface $eventDispatcher, ValidationFailedException $exception)
 {
     $event->stopPropagation();
     $request = $event->getRequest();
     $transaction = $request->get('transaction');
     if (!$transaction) {
         return $event->getResponse();
     }
     $data = $request->get($request->get(Alias::DATA));
     $violations = $exception->getConstraintViolationList();
     $request->attributes->set('violations', $violations);
     $view = View::create($data);
     $responseEvent = new GetResponseForControllerResultEvent($event->getKernel(), $request, $request->getMethod(), $view);
     if ($view->getData() instanceof ArrayCollection) {
         $responseEvent->getRequest()->attributes->set(EmbeddedManager::KEY_EMBED, EmbeddedManager::GROUP_VIOLATION_COLLECTION);
     } else {
         $responseEvent->getRequest()->attributes->set(EmbeddedManager::KEY_EMBED, EmbeddedManager::GROUP_VIOLATION_ENTITY);
     }
     $eventDispatcher->dispatch('kernel.view', $responseEvent);
     return $responseEvent->getResponse();
 }
 /**
  * Get correct response for validation failed exception
  *
  * @param GetResponseForExceptionEvent $event           event
  * @param EventDispatcherInterface     $eventDispatcher eventDispatcher
  * @param ValidationFailedException    $exception       exception
  *
  * @return Response|null
  */
 private function getValidationFailedExceptionResponse(GetResponseForExceptionEvent $event, EventDispatcherInterface $eventDispatcher, ValidationFailedException $exception)
 {
     $event->stopPropagation();
     $request = $event->getRequest();
     $transaction = $request->get('transaction');
     if (!$transaction) {
         return $event->getResponse();
     }
     $data = $request->get($request->get(Alias::DATA));
     $violations = $exception->getConstraintViolationList();
     $request->attributes->set('violations', $violations);
     $view = View::create($data);
     $responseEvent = new GetResponseForControllerResultEvent($event->getKernel(), $request, $request->getMethod(), $view);
     $eventDispatcher->dispatch('kernel.view', $responseEvent);
     $responseData = $view->getData();
     if ($responseData instanceof EmbeddedInterface) {
         $responseData->setShowAssociations(true);
     }
     if ($responseData instanceof CollectionResponse) {
         $responseData->setInheritedShowAssociations(false);
     }
     return $responseEvent->getResponse();
 }