1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App\Twig;
use App\Entity\GlobalParameter;
use App\Entity\SolidoumeParameter;
use Doctrine\ORM\EntityManager;
use Twig\Extension\AbstractExtension;
use Twig\Extension\GlobalsInterface;
class MlcGlobalsExtension extends AbstractExtension implements GlobalsInterface
{
protected $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function getGlobals()
{
$arrayGlobals = $this->em->getRepository(GlobalParameter::class)->findAllByName();
// DEFAULT MAP CENTER & ZOOM : to have a working map on center of France
if (!isset($arrayGlobals['KOH_MAP_CENTER'])) {
$arrayGlobals['KOH_MAP_CENTER'] = '[46.898,3.230]';
}
if (!isset($arrayGlobals['KOH_MAP_ZOOM'])) {
$arrayGlobals['KOH_MAP_ZOOM'] = '6';
}
// $solidoumeParam = $this->em->getRepository(SolidoumeParameter::class)->findTheOne();
// if (!empty($solidoumeParam)) {
// foreach ($solidoumeParam as $key => $param) {
// $arrayGlobals['SD_'.$key] = $param;
// }
// }
return $arrayGlobals;
}
}