How to get the dispatched route name in Zend framework?
Asked Answered
W

3

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

Walking answered 3/9, 2009 at 14:2 Comment(0)
B
41
Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName()
Bookshelf answered 28/10, 2009 at 12:24 Comment(1)
That doesn't seem to work in Zend Framework 1.10.6. Any alternative?Woe
A
8
Zend_Controller_Front::getInstance()->getRouter()->getCurrentRoute()
Anglesey answered 3/9, 2009 at 15:18 Comment(0)
L
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

Lacerta answered 23/10, 2011 at 23:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.