Question

I have a Drupal module that talks to a REST API on a separate server for user registration and authentication. The module runs on multiple sites which point to different servers which may run different versions of the REST API.

Ideally, I'd like to be able to run each site against its own end-point, in case changes on the back end break things. Is there a way to dynamically specify a different end-point URL when running a test? Or do I have to edit the .test file for each site?

I'm trying to keep the module's files as generic and flexible as possible. I guess I could have the .test file look for a .inc file that could override the URL, if needed for a particular site. Is there a better way though?

Was it helpful?

Solution

You can use a variable, using variable_get, and define the site url in settings.php, using a $conf override:

In the .test file: variable_get('endpoint_url', NULL); and in settings.php: $conf['endpoint_url'] = 'http://foo/bar';. That way, for each site, you need only edit settings.php.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top