Reputation: 21
I need to know how to get the current module name in the bootstrap file of my zend application. On the load of the page I'm doing a request to a webservice to get the current user information by sending a hashed cookie and a token. The problem is that I only need to do this in two of my 3 modules so i need to be able to ask for example.
if ($moduleName !== "filteredmodule"){ // do the request }
Thanks.
Upvotes: 1
Views: 5949
Reputation: 464
One thing regarding Ashley's answer:
If you want to do
$module = $request->getModuleName();
as soon as possible, then do it in routeShutdown().
As the documentation states, "routeStartup() is called before Zend_Controller_Front calls on the router to evaluate the request against the registered routes. routeShutdown() is called after the router finishes routing the request."
So router dependant request parameters like module, controller, action or any other parameters specified in the route will be accessible in routeShutdown() and later functions.
Upvotes: 0
Reputation: 5947
Bootstrap is for getting the application ready. I suggest you do this kind of call in a Controller Plugin (which you can use to get the current called module) or in the init() function of your controller.
This is how to get the current module via controller plugin:
<?php
final class YourApp_Controller_Plugin_YourPluginName extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request) {
$module = $request->getModuleName(); //This is the module
Docs: http://framework.zend.com/manual/en/zend.controller.plugins.html
Upvotes: 5