I would like to load a plugin and switch to its theme (and logic) based on a subdomain, so far so good - this could be easily done in Application.php “addPlugin” and later in AppController “viewBuilder”.
But, as soon as the user is logged in the app should switch to the plugin logic/theme stored as the setting value in the db. Of course, this information is not available at application startup (where the plugin is loaded).
How would you solve this?
Theme switching is easy if i load all available plugins before, but the logic of each plugin should only be avalilbale to users which are allowed to (=has the appropriate setting).