|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Ivory Google Map 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\GoogleMap\Helper\Subscriber\Image; |
|
13
|
|
|
|
|
14
|
|
|
use Ivory\GoogleMap\Helper\Collector\Image\EncodedPolylineCollector; |
|
15
|
|
|
use Ivory\GoogleMap\Helper\Event\StaticMapEvent; |
|
16
|
|
|
use Ivory\GoogleMap\Helper\Event\StaticMapEvents; |
|
17
|
|
|
use Ivory\GoogleMap\Helper\Renderer\Image\Overlay\EncodedPolylineRenderer; |
|
18
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @author GeLo <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class EncodedPolylineSubscriber implements EventSubscriberInterface |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var EncodedPolylineCollector |
|
27
|
|
|
*/ |
|
28
|
|
|
private $encodedPolylineCollector; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var EncodedPolylineRenderer |
|
32
|
|
|
*/ |
|
33
|
|
|
private $encodedPolylineRenderer; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param EncodedPolylineCollector $encodedPolylineCollector |
|
37
|
|
|
* @param EncodedPolylineRenderer $encodedPolylineRenderer |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct( |
|
40
|
|
|
EncodedPolylineCollector $encodedPolylineCollector, |
|
41
|
|
|
EncodedPolylineRenderer $encodedPolylineRenderer |
|
42
|
|
|
) { |
|
43
|
|
|
$this->encodedPolylineCollector = $encodedPolylineCollector; |
|
44
|
|
|
$this->encodedPolylineRenderer = $encodedPolylineRenderer; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param StaticMapEvent $event |
|
49
|
|
|
*/ |
|
50
|
|
|
public function handleMap(StaticMapEvent $event) |
|
51
|
|
|
{ |
|
52
|
|
|
foreach ($this->encodedPolylineCollector->collect($event->getMap()) as $encodedPolylines) { |
|
53
|
|
|
$event->setParameter('path', $this->encodedPolylineRenderer->render($encodedPolylines)); |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritdoc} |
|
59
|
|
|
*/ |
|
60
|
|
|
public static function getSubscribedEvents() |
|
61
|
|
|
{ |
|
62
|
|
|
return [StaticMapEvents::ENCODED_POLYLINE => 'handleMap']; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: