| 1 | <?php |
||
| 22 | class CenterSubscriber implements EventSubscriberInterface |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @var CoordinateRenderer |
||
| 26 | */ |
||
| 27 | private $coordinateRenderer; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param CoordinateRenderer $coordinateRenderer |
||
| 31 | */ |
||
| 32 | 100 | public function __construct(CoordinateRenderer $coordinateRenderer) |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @param StaticMapEvent $event |
||
| 39 | */ |
||
| 40 | 96 | public function handleMap(StaticMapEvent $event) |
|
| 41 | { |
||
| 42 | 96 | $map = $event->getMap(); |
|
| 43 | |||
| 44 | 96 | if ($map->hasStaticOption('center')) { |
|
| 45 | 4 | $center = $map->getStaticOption('center'); |
|
| 46 | 94 | } elseif (!$map->isAutoZoom()) { |
|
| 47 | 72 | $center = $this->coordinateRenderer->render($map->getCenter()); |
|
| 48 | 36 | } |
|
| 49 | |||
| 50 | 96 | if (isset($center)) { |
|
| 51 | 76 | $event->setParameter('center', $center); |
|
| 52 | 38 | } |
|
| 53 | 96 | } |
|
| 54 | |||
| 55 | /** |
||
| 56 | * {@inheritdoc} |
||
| 57 | */ |
||
| 58 | 100 | public static function getSubscribedEvents() |
|
| 62 | } |
||
| 63 |