This is probably a bit niche but anyone especially au fait with the element api here?
On project X I have a custom module within which I am referencing a service from another plugin (bolden/google-maps-api
). If I access the module directly (eg via a controller or variable belonging to my module) then all works fine.
However - if I try and access my module service from within an element api endpoint, then the service doesn't work (or rather returns null when trying to access the third-party plugin/service).
For example, in my endpoint I am calling the service ($location is a string):
$data = MyModule::getInstance()->ServiceName->ServiceMethod( $location );
But this returns the following Response: Call to a member function placeFromText() on null
(the stack trace highlights the corresponding line within my module/service), eg:
$googleMaps = GoogleMapsApi::getInstance();
$result = $googleMaps->googleMapsApiService->placeFromText( $place, 'geometry' );
The same query, when accessed within my module (eg a controller or variable), works fine and returns a data object from the Google Maps API (as expected).
Bit confused - anyone have any thoughts on why this service isn't accessible from my module when accessed via the element API?
Any thoughts on this issue would be much appreciated!
Cole