protected function redirectToReferer($defaultPath)
    {
        if (null !== $request = $this->get('request_stack')->getCurrentRequest()) {
            if (0 < strlen($referer = $request->headers->get('referer'))) {
                return $this->redirect($referer);
            }
        }
        return $this->redirect($defaultPath);
    }