It would be nice to be able to format a url in a portable way inside of a controller, for example for a JSON response. Is there an easy way to do this without creating an instance of Zend_View first?
It would be nice to be able to format a url in a portable
Share
If saying “format URL” you meaning create an url from params,
urlview helper is you answer. You use it in controller the same way as in view and don’t need to create newZend_Viewinstance – if you’re using view renderer you have your helper in$this->view. SoBut if you look into code of
urlview helper, you’ll see, that it’s using router object to assemble routes/url/. So all you need is router object, which you can obtain in several ways, some of them:You can also use HelperBroker, retrieve viewRenderer from there, retrieve a view and run helper method.