Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto register doctrine services #303

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pierredup
Copy link
Contributor

This fixes #277

There are a few different aspects to this PR:

  • This includes the changes in Add support for PHP 8 attributes #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

@norkunas
Copy link
Member

norkunas commented Feb 2, 2021

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

@norkunas
Copy link
Member

norkunas commented Feb 3, 2021

Don't forget to fix conflicts ;)

@norkunas
Copy link
Member

norkunas commented Feb 3, 2021

Also listener test class should be renamed probably

@pierredup
Copy link
Contributor Author

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

if (null !== $metadata->addressGetter) {
return true;
}
@trigger_error(sprintf('The class "%s" is deprecated and will be removed from a future version. Please remove it from your service definition.', self::class));
Copy link
Member

@norkunas norkunas Feb 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@trigger_error(sprintf('The class "%s" is deprecated and will be removed from a future version. Please remove it from your service definition.', self::class));
@trigger_error(sprintf('The class "%s" is deprecated and will be removed in 6.0 version. Please use "%s".', self::class, GeocodeEntityListener::class));

@norkunas
Copy link
Member

norkunas commented Feb 9, 2021

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

@norkunas
Copy link
Member

Friendly ping :)

@pierredup
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GeocoderListener should be automatically registered if ORM is enabled
2 participants