Need help figuring out how to write my zend view helper -


I'm new to Zend Framework and MVC in general, so I'm looking for some advice. We have a base controller There are classes in which we have a few ways to get some user information, account configuration, and so on.

So I am using some methods to write code in various controlling tasks, but now I want to avoid repeating this code and even further I can see this code outside the controller and help I want to take it in because it primarily outputs some javascript. Then the code in the controller will look like this:

$ obj = new SomeModel ($ this-> _getModelConfig ()); $ State = $ obj- & gt; FetchByUser ($ this-> User-> getId ()); // To generate some javascript using this result, see the appropriate amount of logic here ...

$ the -> _ getModelConfig and $ this-> user-> getId () These are the things that I can do in the controller, now my question is, what is the best way to pass the assistant to see the information after I remove this code from the controller?

Should I call in the controller these methods and results in the scene and pick up supporters from there?

I was thinking that the other option was to add some parameters to the assistant and if the parameters are passed then I keep them in the properties of the assistant and I return, and when the standards are said without passing So it works. So it will look like this:

From the controller:

  $ this-> view-> MyHelper ($ this-> User-> getId (), $ This-> _getModelConfig ());  

From view:

   

Helper:

  class extends Zend_View_Helper_MyHelper Zend_View_Helper_Abstract {public $ userId = ''; Public $ config = null; Public function myHelper ($ userId = null, $ config = null) {if ($ userId) {$ this- & gt; UserId = $ userId; $ This- & gt; Config = $ config; } Else {// Work $ obj = new SomeModel ($ this-> config); $ State = $ obj- & gt; FetchByUser ($ this-> UserId); // work here} return $ this; }}  

Any advice is welcome!

Firstly ending the end of style on ASP "$ -> - myHelper ();%>" The tag is bad behavior, it has been said that the logic is being used in the model and the controller is being used to call the model, get the result and see to see that spit.

What will I do, if I only want to pass a bunch of scenes, then I put them in an associative array and send them.

Anyway you should not own ...

"The appropriate results should be sent to the view to prepare some JavaScript using this method ... "In the Controller, I advise you to create a new model which makes this argument content for you, and you call your model in the controller, which would require any argument And then spit out the result of that to see.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -