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\Renderer\Control; |
13
|
|
|
|
14
|
|
|
use Ivory\GoogleMap\Control\CustomControl; |
15
|
|
|
use Ivory\GoogleMap\Helper\Formatter\Formatter; |
16
|
|
|
use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer; |
17
|
|
|
use Ivory\GoogleMap\Map; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author GeLo <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class CustomControlRenderer extends AbstractRenderer |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var ControlPositionRenderer |
26
|
|
|
*/ |
27
|
|
|
private $controlPositionRenderer; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param Formatter $formatter |
31
|
|
|
* @param ControlPositionRenderer $controlPositionRenderer |
32
|
|
|
*/ |
33
|
|
|
public function __construct(Formatter $formatter, ControlPositionRenderer $controlPositionRenderer) |
34
|
|
|
{ |
35
|
|
|
parent::__construct($formatter); |
36
|
|
|
|
37
|
|
|
$this->setControlPositionRenderer($controlPositionRenderer); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return ControlPositionRenderer |
42
|
|
|
*/ |
43
|
|
|
public function getControlPositionRenderer() |
44
|
|
|
{ |
45
|
|
|
return $this->controlPositionRenderer; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param ControlPositionRenderer $controlPositionRenderer |
50
|
|
|
*/ |
51
|
|
|
public function setControlPositionRenderer(ControlPositionRenderer $controlPositionRenderer) |
52
|
|
|
{ |
53
|
|
|
$this->controlPositionRenderer = $controlPositionRenderer; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param CustomControl $customControl |
58
|
|
|
* @param Map $map |
59
|
|
|
* |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
public function render(CustomControl $customControl, Map $map) |
63
|
|
|
{ |
64
|
|
|
$formatter = $this->getFormatter(); |
65
|
|
|
|
66
|
|
|
return $formatter->renderObjectCall( |
67
|
|
|
$map, |
68
|
|
|
$formatter->renderProperty( |
69
|
|
|
'controls['.$this->controlPositionRenderer->render($customControl->getPosition()).']', |
70
|
|
|
'push' |
71
|
|
|
), |
72
|
|
|
[$formatter->renderCall('('.$formatter->renderClosure($customControl->getControl()).')')] |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|