<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* Class HostSubscriber
* @package App\EventSubscriber
*/
class HostSubscriber implements EventSubscriberInterface
{
public function __construct()
{
}
/**
* Host provenant du champ référence de l'entité App\Entity\Www\Sites
* @param RequestEvent $event
* @return void
*/
public function onKernelRequestGetHost(RequestEvent $event)
{
$host = $_SERVER["HTTP_HOST"];
$domainMappings = [
"abcm-refonte.local.atiweb.fr" => "abcm",
"abcmzwei.eu" => "abcm",
"www.abcmzwei.eu" => "abcm",
"abcm-vitrine.atiweb.fr" => "abcm",
"www.abcm-vitrine.atiweb.fr" => "abcm",
"haguenau.abcm-vitrine.atiweb.fr" => "haguenau",
"abcm-haguenau.local.atiweb.fr" => "haguenau",
"haguenau.abcmzwei.eu" => "haguenau",
];
define("WWW_HOST", $domainMappings[$host] ?? "");
}
/**
* @return array[]
*/
public static function getSubscribedEvents()
{
return [
KernelEvents::REQUEST => ['onKernelRequestGetHost', 0],
];
}
}