问题
Current state:
- A router is loaded from xml file
- two route name within the router are going to the same controller and action, for example: www-language-employee and www-language-trainer are going to the same controller and action --> EmployeeController & listemployeeAction
Problem: - Need to know which route name is dispatched/being used from a request.
Example: 1. http://www.mycompany.com/en/trainers/ Expected return value: www-language-trainer
回答1:
Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName()
回答2:
Zend_Controller_Front::getInstance()->getRouter()->getCurrentRoute()
回答3:
In my case :
Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName()
returns Employeecontroller/:listemployee
In Employeecontroller
:
public function listemployeeAction()
{
$this->getRequest()->getParam('listemployee')
}
would return either employee
or trainer
来源:https://stackoverflow.com/questions/1373573/how-to-get-the-dispatched-route-name-in-zend-framework