public function onKernelResponse(KernelEvent $event)
    {
        if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST
            && $this->wasTxStarted
            && $this->doctrine->getConnection()->getTransactionIsolation() > 0) {

            if ($this->doctrine->getConnection()->isRollbackOnly()) {
                $this->doctrine->getConnection()->rollback();
            } else {
                $this->doctrine->getConnection()->commit();
            }
            $this->wasTxStarted = false;
        }
    }