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

Using attribute "Address" on getter will always trigger geocoding #341

Open
fnagel opened this issue Sep 15, 2023 · 2 comments
Open

Using attribute "Address" on getter will always trigger geocoding #341

fnagel opened this issue Sep 15, 2023 · 2 comments

Comments

@fnagel
Copy link

fnagel commented Sep 15, 2023

Using the attribute on a property will only trigger geocoding on change, but using using the #[Geocoder\Address] attribute on a getter method will always trigger geocoding. Is that on purpose?

Looks like this is caused by this guard clause: https://github.com/geocoder-php/BazingaGeocoderBundle/blob/962834628d63ad15a8b5d40ff2da764c73dcde65/src/Doctrine/ORM/GeocoderListener.php#L126C9-L128

I guess there is no easy way to fix this, right? Using #[Geocoder\Address] on multiple properties (like $street $zip, $city, ...) will not work either. Can we add a parameter to the Address attribute / annotation for passing an array of properties?

Any ideas?

Related to #239 and #281

@norkunas
Copy link
Member

norkunas commented Oct 3, 2023

If you use a getter for address, then there is no way to get the change set to detect if the address has changed, therefore I think it's not feasible

@norkunas
Copy link
Member

norkunas commented Oct 3, 2023

Only solution I can think of if we'd introduce some geocodeIf: expression property on the Address attribute.
For example:

#[Geocoder\Address(geocodeIf: 'this.isAddressChanged()')]
public function getAddress(): string { ... }
public function isAddressChanged() { ... }

Or something like that.

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

No branches or pull requests

2 participants