geocoder-php/BazingaGeocoderBundle

Custom provider factory error

minychillo opened this issue · 5 comments

It seems not possible to load custom provider with factory. This line throws an exception in dependency injection extension, as the extension does not have access to the service definitions in the main services.yml ( or am I missing something ? )

$factoryService = $container->getDefinition($providerConfig['factory']);

as the extension does not have access to the service definitions in the main services.yml

Are you sure about that?
Could you post your service declaration and bazinga config?

Btw, here is the related docs: https://github.com/geocoder-php/BazingaGeocoderBundle/blob/master/Resources/doc/custom-provider.md

I tried many different things, but the definition simply is not set in the dependency injection extension. I am definitely no specialist, but the symfony docs explains that the extension has access ONLY to the bundles service definitions.

Here is my bazinga config.

bazinga_geocoder:
  providers:
    acme:
      aliases:
        - geocoder_google
      factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory
      options:
        api_key: 'xxxxxxxxxxxxxxxxxxx'
    geoportail:
      aliases:
        - geocoder_geoportail
      factory: app.core.geoportail_map_provider_factory

And here is a simple service declaration for the factory:

app.core.geoportail_map_provider_factory:
    class: AppBundle\Core\GeoportailMapProviderFactory
    public: true

I was able to reproduce this error. I've merged a fix into master. Please try it out.

Yes, works fine. Many thanks.