Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get request info in view helper

Is it possible in Zend View helper (extends Zend_View_Helper_Abstract) get info about module/controller/action in which that helper was called ?

like image 741
hsz Avatar asked Jan 07 '10 14:01

hsz


1 Answers

Yes. You can use Zend_Controller_Front::getInstance() within view helpers. So you could do something like this:

class App_Helper_DoSomething extends Zend_View_Helper_Abstract
{
    public function doSomething()
    {
        return Zend_Controller_Front::getInstance()
            ->getRequest()
            ->getControllerName();
    }
}

Which will print the current controller name when called in your view with:

echo $this->doSomething();
like image 121
Mark Avatar answered Oct 08 '22 00:10

Mark