/**
  * If there is a logged in user with a preferred language, set it as a cookie.
  *
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     $locale = $this->localeProvider->determinePreferredLocale();
     // Unable to determine preferred locale? No need to hand out a cookie then.
     if (empty($locale)) {
         return;
     }
     // Did the request already contain the proper cookie value? No need to hand out a cookie then.
     $requestCookie = $this->cookieHelper->read($event->getRequest());
     if ($requestCookie && $requestCookie->getValue() === $locale) {
         $this->logger->debug(sprintf('Locale cookie already set to "%s", nothing to do here', $locale));
         return;
     }
     $this->cookieHelper->write($event->getResponse(), $locale);
     $this->logger->notice(sprintf("Set locale cookie to %s", $locale));
 }