|
1
|
|
|
<?php |
|
2
|
|
|
/*************************************************************************************/ |
|
3
|
|
|
/* This file is part of the Thelia package. */ |
|
4
|
|
|
/* */ |
|
5
|
|
|
/* Copyright (c) OpenStudio */ |
|
6
|
|
|
/* email : [email protected] */ |
|
7
|
|
|
/* web : http://www.thelia.net */ |
|
8
|
|
|
/* */ |
|
9
|
|
|
/* For the full copyright and license information, please view the LICENSE.txt */ |
|
10
|
|
|
/* file that was distributed with this source code. */ |
|
11
|
|
|
/*************************************************************************************/ |
|
12
|
|
|
/*************************************************************************************/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Dealer\Hook; |
|
15
|
|
|
|
|
16
|
|
|
use Dealer\Dealer; |
|
17
|
|
|
use Symfony\Component\Routing\Router; |
|
18
|
|
|
use Thelia\Core\Event\Hook\HookRenderBlockEvent; |
|
19
|
|
|
use Thelia\Core\Event\Hook\HookRenderEvent; |
|
20
|
|
|
use Thelia\Core\Hook\BaseHook; |
|
21
|
|
|
use Thelia\Core\Security\AccessManager; |
|
22
|
|
|
use Thelia\Core\Security\SecurityContext; |
|
23
|
|
|
use Thelia\Core\Translation\Translator; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class AdminInterfaceHook |
|
27
|
|
|
*/ |
|
28
|
|
|
class AdminInterfaceHook extends BaseHook |
|
29
|
|
|
{ |
|
30
|
|
|
protected $router; |
|
31
|
|
|
|
|
32
|
|
|
protected $securityContext; |
|
33
|
|
|
|
|
34
|
|
|
public function __construct(Router $router, SecurityContext $securityContext) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->router = $router; |
|
37
|
|
|
$this->securityContext = $securityContext; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
protected function transQuick($id, $locale, $parameters = []) |
|
41
|
|
|
{ |
|
42
|
|
|
if ($this->translator === null) { |
|
43
|
|
|
$this->translator = Translator::getInstance(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
return $this->trans($id, $parameters, Dealer::MESSAGE_DOMAIN, $locale); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function onMainTopMenuTools(HookRenderEvent $event) |
|
50
|
|
|
{ |
|
51
|
|
|
$isGranted = $this->securityContext->isGranted( |
|
52
|
|
|
["ADMIN"], |
|
53
|
|
|
[], |
|
54
|
|
|
[Dealer::getModuleCode()], |
|
55
|
|
|
[AccessManager::VIEW] |
|
56
|
|
|
); |
|
57
|
|
|
|
|
58
|
|
|
if ($isGranted) { |
|
59
|
|
|
$event->add($this->render("menu-hook.html", $event->getArguments())); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|