I am trying to get the header in the constructor class constructor
$ this - & gt; Parameter () - & gt; FromHeader (); But this is not working any other way of getting the header in the manufacturer
I am sending the User ID to the header so I want to Will this be possible in the constructor?
Thank you.
It seems that you want to get user id from the header header. The short answer is yes, it is possible. But doing so can not be translated immediately by all MVC controllers within the constructor .
What you need onDispatch () Check the header value before sending the actual action to the system administrator.
Try this:
& lt ;? Php namespace application \ controller; Zend \ Mvc \ Controller \ AbstractActionController; Use Zend \ Mvc \ MvcEvent; Class MyController extends AbstractActionController {/ ** * Send event * * @ Ultimate MvcEvent $ event * / Dispatches (MvcEvent $ e) on public functions {$ headers = $ e- & gt; GetRequest () - & gt; GetHeaders (); If ($ headers- & gt; is ('user')) {// user header has been provided. $ Header = $ header- & gt; Receive ('user'); // ... what you want with this heading here } // Do not forget to trigger the dispatch of the parent Return parent: On Dispatches ($ E); }
No comments:
Post a Comment