1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Ivory Google Map bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ivory\GoogleMapBundle\DependencyInjection\Compiler; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; |
15
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
17
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
18
|
|
|
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; |
19
|
|
|
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author GeLo <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class RegisterHelperListenerPass implements CompilerPassInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var string[] |
28
|
|
|
*/ |
29
|
|
|
private static $helpers = [ |
30
|
|
|
'api', |
31
|
|
|
'map', |
32
|
|
|
'map.static', |
33
|
|
|
'place_autocomplete', |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var RegisterListenersPass[] |
38
|
|
|
*/ |
39
|
|
|
private $passes = []; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
684 |
|
public function __construct() |
45
|
|
|
{ |
46
|
684 |
|
foreach (self::$helpers as $helper) { |
47
|
684 |
|
$this->passes[] = new RegisterListenersPass( |
48
|
684 |
|
'ivory.google_map.helper.'.$helper.'.event_dispatcher', |
49
|
684 |
|
'ivory.google_map.helper.'.$helper.'.listener', |
50
|
684 |
|
'ivory.google_map.helper.'.$helper.'.subscriber' |
51
|
532 |
|
); |
52
|
532 |
|
} |
53
|
684 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
513 |
|
public function process(ContainerBuilder $container) |
59
|
|
|
{ |
60
|
513 |
|
if (!class_exists(ServiceClosureArgument::class)) { |
61
|
513 |
|
foreach (self::$helpers as $helper) { |
62
|
|
|
$container |
63
|
513 |
|
->getDefinition('ivory.google_map.helper.'.$helper.'.event_dispatcher') |
64
|
513 |
|
->setClass(ContainerAwareEventDispatcher::class) |
65
|
513 |
|
->addArgument(new Reference('service_container')); |
66
|
399 |
|
} |
67
|
399 |
|
} |
68
|
|
|
|
69
|
513 |
|
foreach ($this->passes as $pass) { |
70
|
513 |
|
$pass->process($container); |
71
|
399 |
|
} |
72
|
513 |
|
} |
73
|
|
|
} |
74
|
|
|
|