1 | <?php |
||
20 | class PlaceAutocompleteExtension extends \Twig_Extension |
||
21 | { |
||
22 | /** |
||
23 | * @var PlaceAutocompleteHelper |
||
24 | */ |
||
25 | private $placeAutocompleteHelper; |
||
26 | |||
27 | /** |
||
28 | * @param PlaceAutocompleteHelper $placeAutocompleteHelper |
||
29 | */ |
||
30 | 27 | public function __construct(PlaceAutocompleteHelper $placeAutocompleteHelper) |
|
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | 27 | public function getFunctions() |
|
39 | { |
||
40 | 27 | $functions = []; |
|
41 | |||
42 | 27 | foreach ($this->getMapping() as $name => $method) { |
|
43 | 27 | $functions[] = new \Twig_SimpleFunction($name, [$this, $method], ['is_safe' => ['html']]); |
|
44 | 21 | } |
|
45 | |||
46 | 27 | return $functions; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * @param Autocomplete $autocomplete |
||
51 | * @param string[] $attributes |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | 9 | public function render(Autocomplete $autocomplete, array $attributes = []) |
|
61 | |||
62 | /** |
||
63 | * @param Autocomplete $autocomplete |
||
64 | * @param string[] $attributes |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 9 | public function renderHtml(Autocomplete $autocomplete, array $attributes = []) |
|
74 | |||
75 | /** |
||
76 | * @param Autocomplete $autocomplete |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | 9 | public function renderJavascript(Autocomplete $autocomplete) |
|
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | 27 | public function getName() |
|
92 | |||
93 | /** |
||
94 | * @return string[] |
||
95 | */ |
||
96 | 27 | private function getMapping() |
|
104 | } |
||
105 |