How to get the dispatched route name in Zend framework?

故事扮演 提交于 2019-11-29 11:17:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!