Hi,

I am writing a custom default router where by the module is dependent on the sub-domain, for example:

domain.com -> default
www.domain.com -> default
admin.domain.com -> admin
anything-else.domain.com -> account

The theory behind this is similar to the following in rails: 
http://wiki.rubyonrails.org/rails/pages/HowToUseSubdomainsAsAccountKeys

My router is based on Zend_Controller_Router_Route_Module, however adding the route in my bootstrap class it is always NULL.

$dispatcher = $this->_controller->getDispatcher();
$request = $this->_controller->getRequest();
$router = $this->_controller->getRouter();
$router->addRoute('default', new App_Controller_Router_Route_AccountKey(array(), $dispatcher, $request));

I have managed to solve the problem by instantiating a request object and assigning it to the front-controller as well as passing it to the route.

$dispatcher = $this->_controller->getDispatcher();
$request = new Zend_Controller_Request_Http();
$this->_controller->setRequest($request);
$router = $this->_controller->getRouter();
$router->addRoute('default', new App_Controller_Router_Route_AccountKey(array(), $dispatcher, $request));

Is this my only option and is it the right one? My router seems to work well other than this but I would be interested to hear about any other custom routers people have written that do the same job.

Thanks,

Tom

Reply via email to