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; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @author GeLo <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class ApiInitRenderer extends AbstractRenderer |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @param string $name |
21
|
|
|
* @param \SplObjectStorage $callbacks |
22
|
|
|
* @param \SplObjectStorage $requirements |
23
|
|
|
* @param string[] $sources |
24
|
|
|
* @param string $sourceCallback |
25
|
|
|
* @param string $requirementCallback |
26
|
|
|
* @param bool $newLine |
27
|
|
|
* |
28
|
|
|
* @return string |
29
|
|
|
*/ |
30
|
276 |
|
public function render( |
31
|
|
|
$name, |
32
|
|
|
\SplObjectStorage $callbacks, |
33
|
|
|
\SplObjectStorage $requirements, |
34
|
|
|
array $sources, |
35
|
|
|
$sourceCallback, |
36
|
|
|
$requirementCallback, |
37
|
|
|
$newLine = true |
38
|
|
|
) { |
39
|
276 |
|
$formatter = $this->getFormatter(); |
40
|
276 |
|
$separator = $formatter->renderSeparator(); |
41
|
276 |
|
$codes = []; |
42
|
|
|
|
43
|
276 |
|
foreach ($sources as $source) { |
44
|
52 |
|
$codes[] = $formatter->renderCall($sourceCallback, [$formatter->renderEscape($source)], true); |
45
|
138 |
|
} |
46
|
|
|
|
47
|
276 |
|
foreach ($callbacks as $object) { |
48
|
276 |
|
$codes[] = $formatter->renderCall($requirementCallback, [ |
49
|
276 |
|
$callbacks[$object], |
50
|
276 |
|
$formatter->renderClosure($formatter->renderCode( |
51
|
276 |
|
'return '.implode( |
52
|
276 |
|
$separator.'&&'.$separator, |
53
|
276 |
|
isset($requirements[$object]) ? $requirements[$object] : [] |
54
|
138 |
|
), |
55
|
276 |
|
true, |
56
|
138 |
|
false |
57
|
138 |
|
)), |
58
|
276 |
|
], true); |
59
|
138 |
|
} |
60
|
|
|
|
61
|
276 |
|
return $formatter->renderClosure($formatter->renderLines($codes, true, false), [], $name, true, $newLine); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|