I am currently working on an internal project that would host a Drupal multisite platform.
For this, I am in the process of creating a site_manager module that will be running in the "main" Drupal instance, within the multisite setup.
Now, I want to be able to run a lot of functions in the context of a specific subsite.
For example: I want to run a cache_clear_all() or a module_enable() in a subsite.
When I call these functions, it will always run the functions in the current site's context (the "main" Drupal instance).
I have tried to use db_set_active() to resolve this, but no luck. It will always run it in the current "main" site.
To resolve the problem I started implementing a custom class that holds methods for the actions I want to perform, that fire custom db_query() implementations...
It works, but that cannot be the cleanest way to do this... Clearing the cache tables manually via db_query does not seem like the best way to do this, especially when you know that just calling cache_clear_all() should do the trick, when ran in the correct context.
Some research brought me here: Programmatically create user in another Drupal site But I don't really see how this would work, because I want the platform to be extendible,so that I can add functions later.
I could try to setup some kind of "client" module that listens for calls from the main site or something like this?
After doing some additional research, I am looking into the possibilities of XML-RPC or some kind of webservice (json) that might do the trick as well.
It might be good to note that I would like to find a sustainable solution when looking forward to D8...
Anyway, did any of you try something like this?
Thanks in advance!