Skip to content

Conversation

@Adnan-cds
Copy link
Contributor

This is a plugin for Drupal's Geocoder module. Useful for UK address lookup.

I am bringing these files from the localgov_forms module. This one is blocked by another pull request for the newly created localgovdrupal/localgov_os_places_geocoder_provider composer package.

Test steps (for now)

$ composer require localgovdrupal/localgov_geo:'dev-feature/os-places-geocoder-plugin as 1.1.1'
$ composer require --dev localgovdrupal/localgov_os_places_geocoder_provider:dev-feature/provider
$ drush -y en geocoder localgov_geo

Now add the Localgov OS Places Geocoder plugin from /admin/config/system/geocoder/geocoder-provider. This step, unfortunately, asks for an API key.

I am marking this pull request as Draft until localgovdrupal/localgov_os_places_geocoder_provider is ready.

This is a plugin for Drupal's Geocoder module.  Useful for address lookup.

The actual PHP Geocoder for the OS Places API is provided by the
localgovdrupal/localgov_os_places_geocoder_provider package.  This plugin is a
Drupal specific wrapper over the OS Places PHP Geocoder.

API details: https://osdatahub.os.uk/docs/places/overview
Drupal schema definition for our OS Places Drupal plugin configuration.
@Adnan-cds Adnan-cds marked this pull request as draft October 19, 2021 15:11
@Adnan-cds Adnan-cds requested review from ekes and stephen-cox October 19, 2021 15:11
@andybroomfield
Copy link
Contributor

I'm just trying this, but it wont appear.
There seems to be some namespacing issues with either the handler, or the geocoder plugin.
\LocalgovDrupal\OsPlacesGeocoder\Provider\LocalgovOsPlacesGeocoder put the plugin installs under localgovdrupal/localgov_os_places_geocoder.

Updated the PHP Geocoder class name to match the latest.
@Adnan-cds Adnan-cds marked this pull request as ready for review November 30, 2021 16:54
@Adnan-cds
Copy link
Contributor Author

Hi Andy,
Sorry, the class name for the OS Places PHP Geocoder plugin changed during code review. All fixed now and ready for review.

@andybroomfield
Copy link
Contributor

Thanks @Adnan-cds however this is still not working becuase the geocoder gets installed in localgov_os_places_geocoder_provider not OsPlacesGeocoder.

Even with localgov_geo enabled and this branch checked out and localgovdrupal/localgov_os_places_geocoder_provider intalled via composer require, I am not seeing Localgov OS Places as a provider in the drop down menu to add a geocoder provider at /admin/config/system/geocoder/geocoder-provider

@Adnan-cds
Copy link
Contributor Author

however this is still not working

That's worrying Andy. Good morning by the way.

the geocoder gets installed in localgov_os_places_geocoder_provider not OsPlacesGeocoder.

This should be taken care of by composer's autoloader declaration. In any case, try composer dump-autoload to recreate the site-wide class autoloader files.

I am not seeing Localgov OS Places as a provider in the drop down menu

Assuming you have already cleared the Drupal cache after fetching the latest code, may I ask if this is happening in a fresh LocalGov site or an existing site?

@andybroomfield
Copy link
Contributor

andybroomfield commented Dec 3, 2021

@Adnan-cds So I did this on a fresh install and that worked ok.
This is on the development copy nativly on my mac, the place I'm having issue is the copy that runs under Lando, so I'm trying to work out if it was the fresh install or the fact its Lando that is the problem.

@andybroomfield
Copy link
Contributor

Update, using the example code that is included in the module I get this error
The website encountered an unexpected error. Please try again later.
Error: Class 'LocalgovDrupal\OsPlacesGeocoder\Provider\OsPlacesGeocoder' not found in localgov_geo_preprocess_page()

So its the class itself that is not being found.

@Adnan-cds
Copy link
Contributor Author

Error: Class 'LocalgovDrupal\OsPlacesGeocoder\Provider\OsPlacesGeocoder' not found in localgov_geo_preprocess_page()

Thanks for persisting with this Andy. Could you please check the vendor/composer/autoload_psr4.php file for mentions of LocalgovDrupal. In my local development site, I can see two mentions:

'LocalgovDrupal\\OsPlacesGeocoder\\Tests\\' => array($vendorDir . '/localgovdrupal/localgov_os_places_geocoder_provider/tests'),
'LocalgovDrupal\\OsPlacesGeocoder\\' => array($vendorDir . '/localgovdrupal/localgov_os_places_geocoder_provider/src'),

@andybroomfield
Copy link
Contributor

Thanks @Adnan-cds Yes I have both those entries.

    'LocalgovDrupal\\OsPlacesGeocoder\\Tests\\' => array($vendorDir . '/localgovdrupal/localgov_os_places_geocoder_provider/tests'),
    'LocalgovDrupal\\OsPlacesGeocoder\\' => array($vendorDir . '/localgovdrupal/localgov_os_places_geocoder_provider/src'),

I think this may have been a Lando issue.
I've just done a lando rebuild to get it to recongnise and now it has started working.
Maybe there is something strange with directory scanning between lando docker container and the mac directory structure?

@ekes
Copy link
Member

ekes commented Dec 3, 2021

The plugin was detected, but not found, that'd be new. But (and iirc lando does have apcu enabled):-

https://www.drupal.org/project/geocoder/issues/3153678#comment-14203727

@ekes
Copy link
Member

ekes commented Dec 6, 2021

OK so this is good for me I think.
Did you solve your issues @andybroomfield then could add a review and get it merged?

Copy link
Member

@ekes ekes left a comment

Choose a reason for hiding this comment

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

Pending confirmation about issues about namespace / plugin appearing - good.

@andybroomfield
Copy link
Contributor

Yes this is solved, might need some documentation update though. I had to do a Lando rebuild to get it to apply.
I suspect it was having some old code in there somewhere..?

Adding basic description and pitfalls of using the OS Places geocoder plugin.
@Adnan-cds
Copy link
Contributor Author

Hi Andy, I have added a new section in the README about this new OS places geocoder plugin. Please let me know if this will do.

@andybroomfield
Copy link
Contributor

Merging as per December 13th Merge Monday.

@andybroomfield andybroomfield merged commit a49936d into 1.x Dec 13, 2021
@andybroomfield andybroomfield mentioned this pull request Dec 13, 2021
@Adnan-cds
Copy link
Contributor Author

Hi Andy, Ekes, thanks for getting this in :)

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.

4 participants