18

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

mega6382
  • 9,211
  • 17
  • 48
  • 69

3 Answers3

41
Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName()
Murat Çorlu
  • 8,207
  • 5
  • 53
  • 78
8
Zend_Controller_Front::getInstance()->getRouter()->getCurrentRoute()
Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82
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

Sparkup
  • 3,686
  • 2
  • 36
  • 50