I’m building a GooglePlaces API, it is package as an http datasource.
I thought it would be a good idea to ship it with a basic Places model & a basic gplaces connection so that the datasource could be used out of the box in my app PlacesController using :
use appmodelsPlaces;
use googlemodelsPlaces as GPlaces;
class PlacesController extends lithiumactionController { ... }
But i’d like to be able to somehow surcharge the plugin default connection gplaces with so API key.
Tried :
GPlaces::config(array(
'key' => '<private_api_key>'
));
But it does not affect (as we could expect) the Connection,
Any ideas ?
Advertisement
Answer
In this instance, GPlaces is a model, so doing this is only going to assign that key to the model’s configuration, which is not what you want.
If you have a connection called 'gplaces', it should be configured with that key in Connections::add(), then you can tell your model to use that connection like so:
GPlaces::config(array(
'connection' => 'gplaces'
));