BazingaGeocoderBundle icon indicating copy to clipboard operation
BazingaGeocoderBundle copied to clipboard

Auto register doctrine services

Open pierredup opened this issue 4 years ago • 7 comments

This fixes #277

There are a few different aspects to this PR:

  • This includes the changes in #302
  • Add support to define the provider per entity This is added with a new provider option on the Geocodable class, which can be used to define a different provider for each entity:

#[Geocodable(povider: 'foo')]
class User {}

#[Geocodable(povider: 'bar')]
class DifferentUser {}
  • This deprecates the GeocoderListener class in favor of a new GeocodeEntityListener class. The reason for this is so that we can auto-register the GeocodeEntityListener class when Doctrine is available, and automatically have a lookup for each provider. All the different providers are added to a service-locator, which is then used to look up the provider for an entity in the listener.
  • Add a new ChainDriver for metadata, where all the different metadata drivers are added (AttributeDriver and AnnotationDriver) This allows to quickly switch between using annotations to using attributes without needing to make any config or service changes

pierredup avatar Feb 01 '21 16:02 pierredup

Many thanks :) I'd also an option to disable listener (because personally I don't use it)

norkunas avatar Feb 02 '21 04:02 norkunas

Don't forget to fix conflicts ;)

norkunas avatar Feb 03 '21 05:02 norkunas

Also listener test class should be renamed probably

norkunas avatar Feb 03 '21 05:02 norkunas

I rebased against master. I'll finish this one in the next few days

pierredup avatar Feb 03 '21 06:02 pierredup

An example with Geocodable attribute and using provider would be good to add in readme

norkunas avatar Feb 09 '21 04:02 norkunas

Friendly ping :)

norkunas avatar Feb 18 '21 05:02 norkunas

@norkunas Sorry for not getting to this earlier, other projects kept me very busy. I'll only be able to finish this by next week.

pierredup avatar Feb 22 '21 07:02 pierredup