heimrichhannot / contao-google-maps-bundle

This bundle adds google maps integration to Contao.
2 stars 8 forks source link

Fix service initiation with nullable model #18

Closed rabauss closed 2 years ago

rabauss commented 2 years ago

The model can be null on automatic initation via DI - so the type should be also nullable

koertho commented 2 years ago

This listener isn't intended for the DI container, so I think it would be better to skip it in the service definition. WDYT?

koertho commented 2 years ago

It's only used here as far as I see: https://github.com/heimrichhannot/contao-google-maps-bundle/blob/62b5a1c3e12b457e0c49aa05d3e7efc4f0ed2809/src/Manager/MapManager.php#L183

rabauss commented 2 years ago

Yes, this could be also a solution - but I was not sure if it was intended to initalize the MapRendererListener as service!

koertho commented 2 years ago

I don't wrote this part of code, but I don't think that this was intended, so I would prefer the "skip-way", as it looks cleaner to me.

rabauss commented 2 years ago

I realized that I was missing the third param of renderMapObject in a custom implementation with the MapManager. So the $templateData['mapConfigModel'] was not set and caused the error with the MapRendererListener.

https://github.com/heimrichhannot/contao-google-maps-bundle/blob/62b5a1c3e12b457e0c49aa05d3e7efc4f0ed2809/src/Manager/MapManager.php#L183

We can close this PR - although I think an exclude in the services.yml would not be wrong:

//src/Resources/config/services.yml
  HeimrichHannot\GoogleMapsBundle\:
    resource: '../../{EventListener,EventSubscriber}/*'
    exclude: '../../EventListener/MapRendererListener.php'
koertho commented 2 years ago

I've skipped the service in 9e27d3a

koertho commented 2 years ago

Thanks anyway @rabauss !