|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the XiideaEasyAuditBundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Xiidea <http://www.xiidea.net> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Xiidea\EasyAuditBundle\Traits; |
|
13
|
|
|
|
|
14
|
|
|
trait ServiceContainerGetterMethods |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @throws \Exception |
|
19
|
|
|
* @return \Symfony\Component\DependencyInjection\ContainerInterface |
|
20
|
|
|
*/ |
|
21
|
|
|
protected abstract function getContainer(); |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @return \Xiidea\EasyAuditBundle\Resolver\EventResolverInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
public function getCommonResolver() |
|
27
|
|
|
{ |
|
28
|
|
|
return $this->getService($this->getParameter('resolver')); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
public function getService($serviceName) |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->getContainer()->get($serviceName); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return boolean|\Symfony\Component\HttpFoundation\Request |
|
39
|
|
|
*/ |
|
40
|
|
|
public function getRequest() |
|
41
|
|
|
{ |
|
42
|
|
|
try { |
|
43
|
|
|
return $this->getService('request_stack')->getCurrentRequest(); |
|
44
|
|
|
} catch (\Exception $e) { |
|
45
|
|
|
return false; |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return \Xiidea\EasyAuditBundle\Resolver\EventResolverInterface |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getEntityEventResolver() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->getService($this->getParameter('entity_event_resolver')); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param string $parameter |
|
59
|
|
|
* @return mixed |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getParameter($parameter) |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->getContainer()->getParameter('xiidea.easy_audit.'.$parameter); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return \Symfony\Component\HttpKernel\KernelInterface |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getKernel() |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->getService('kernel'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return boolean |
|
76
|
|
|
*/ |
|
77
|
|
|
public function isDebug() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->getKernel()->isDebug(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getDoctrineEventsList() |
|
83
|
|
|
{ |
|
84
|
|
|
$reflectionClass = new \ReflectionClass('Xiidea\EasyAuditBundle\Events\DoctrineEvents'); |
|
85
|
|
|
return $reflectionClass->getConstants(); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|