public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); $currentHost = $request->getHost(); $subdomain = str_replace('.' . $this->baseHost, '', $currentHost); if ("www" === $subdomain) { return; } $conference = $this->om->getRepository('AppBundle:Conference')->findOneBy(array('code' => $subdomain)); if (!$conference) { throw new NotFoundHttpException(sprintf('No site for host "%s", subdomain "%s"', $this->baseHost, $subdomain)); } $this->cm->setConference($conference); }