Total Complexity | 6 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 33.33% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | class StyleSubscriber implements EventSubscriberInterface |
||
22 | { |
||
23 | /** @var StyleRenderer */ |
||
24 | private $styleRenderer; |
||
25 | |||
26 | 1 | public function __construct(StyleRenderer $styleRenderer) |
|
27 | { |
||
28 | 1 | $this->styleRenderer = $styleRenderer; |
|
29 | 1 | } |
|
30 | |||
31 | public function handleMap(StaticMapEvent $event): void |
||
32 | { |
||
33 | $map = $event->getMap(); |
||
34 | |||
35 | if (!$map->hasMapOption('styles')) { |
||
36 | return; |
||
37 | } |
||
38 | |||
39 | $styles = []; |
||
40 | |||
41 | foreach ($map->getStaticOption('styles') as $style) { |
||
42 | $styles[] = $this->styleRenderer->render($style); |
||
43 | } |
||
44 | |||
45 | if (!empty($styles)) { |
||
46 | $event->setParameter('style', $styles); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | /** {@inheritdoc} */ |
||
51 | 1 | public static function getSubscribedEvents(): array |
|
54 | } |
||
55 | } |
||
56 |