How to get the dispatched route name in Zend frame

2019-02-05 21:44发布

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

3条回答
ら.Afraid
2楼-- · 2019-02-05 22:02
Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName()
查看更多
疯言疯语
3楼-- · 2019-02-05 22:02
Zend_Controller_Front::getInstance()->getRouter()->getCurrentRoute()
查看更多
老娘就宠你
4楼-- · 2019-02-05 22:03

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

查看更多
登录 后发表回答