I'm working on multi-tenant application in Zend Framework which gets it's tenantID from the subdomain name (mod_rewrite -> index.php -> matches it against the database).
My question is - how do I set this variable (tenant id) to be available for every Controller?
Leonti
Yes, Zend_Registry can be used for that. Another thing you can do is registering a pre-dispatch controller plugin, which will add the tenantID as a request parameter before any controller receives it:
class YourApp_Plugin_IdWriter extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request) {
$request->setParam('tenantID', ...);
}
}
You need to register the plugin in your application.ini:
resources.frontController.plugins.access = "YourApp_Plugin_IdWriter"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With