Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2: Is better to use session object or my own manager?
    text
    copied!<p>Related to <a href="https://stackoverflow.com/questions/12479187/something-that-escapes-me-about-symfonys-controllers">that</a> question.<br/> I've understood that I have to create some services for handle my entity and so on. That's because I have to "move" my logic away from controllers and place into "managers" (i.e. services)</p> <p>Now I have a service that have some logic into it. In that service I, depending on user, return a list of "associated object" - say that those object are sport's team.<br/> Let's say that first element of my list (generated from a repository somehow) is the "default" team and say that I have a page were I can change it <strong>FOR all session long</strong>. <br/> After log out or sessions stale, I want to return at "default" situation.</p> <p>So my idea was: "since I've wrote a manager for this entity, I'll write a private attribute in this class where load (from db) this property and store (temporarily, with setter method) my changes."<br/> This doesn't affect my db and I can keep my information for all session long.</p> <p>But a thought came into my mind: how about session object? (is a service, if I didn't understood wrong)<br/> Is my solution a good solution, or is better to store my information into session object?<br/> From my point of view it's the same except that I can read session's variables directly from twig by using <code>app.session</code>. Am I wrong?</p> <p>Moreover, if I'm not wrong, how can I access my object properties from twig without each time pass them from controller? (is much like having a global variable that I want to display everywhere into my application pages).</p> <p><strong>Edit:</strong></p> <p>More information can be found in <a href="http://chat.stackoverflow.com/transcript/message/5425143#5425143">this chat transcript</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload