ninesurvey/src/ninesurvey-1.0/src/Service/sessionInit.php

74 lines
3.1 KiB
PHP

<?php
namespace App\Service;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpFoundation\Session\Session;
use Doctrine\ORM\EntityManager;
class sessionInit {
private $container;
protected $em;
protected $session;
public function __construct(ContainerInterface $container, EntityManager $em,Session $session)
{
$this->container = $container;
$this->session = $session;
$this->em = $em;
}
public function onDomainParse(RequestEvent $event) {
$configs = $this->em->getRepository("App:Config")->findAll();
foreach($configs as $config) {
$this->session->set($config->getId(), strval($config->getValue()));
}
// Valeur par défaut appname
if($this->session->get("appname")=="")
$this->session->set("appname", $this->container->getParameter('appName'));
// Valeur par defaut colorbgbodydark = #343a40
if($this->session->get("colorbgbodydark")=="")
$this->session->set("colorbgbodydark", '#343a40');
// Valeur par defaut colorbgbodydark = #ffffff
if($this->session->get("colorbgbodylight")=="")
$this->session->set("colorbgbodylight", '#ffffff');
// Valeur par defaut colorfttitledark = #ffffff
if($this->session->get("colorfttitledark")=="")
$this->session->set("colorfttitledark", '#ffffff');
// Valeur par defaut colorfttitlelight = #343a40
if($this->session->get("colorfttitlelight")=="")
$this->session->set("colorfttitlelight", '#343a40');
// Valeur par defaut colorftbodydark = #ffffff
if($this->session->get("colorftbodydark")=="")
$this->session->set("colorftbodydark", '#ffffff');
// Valeur par defaut colorftbodylight = #343a40
if($this->session->get("colorftbodylight")=="")
$this->session->set("colorftbodylight", '#343a40');
// Valeur par defaut fonttitle = FredokaOne-Regular
if($this->session->get("fonttitle")=="")
$this->session->set("fonttitle", 'FredokaOne-Regular');
// Valeur par defaut fontbody = Roboto-Regular
if($this->session->get("fontbody")=="")
$this->session->set("fontbody", 'Roboto-Regular');
// Valeur par defaut logo
if($this->session->get("logodark")==""&&$this->session->get("logolight")=="") {
$this->session->set("logodark", "logo.png");
$this->session->set("logolight", "logo.png");
}
elseif($this->session->get("logodark")=="")
$this->session->set("logodark", $this->session->get("logolight"));
elseif($this->session->get("logolight")=="")
$this->session->set("logolight", $this->session->get("logodark"));
}
}