How can I pass session variable in symfony model without using sfContext::getInstance()?
How can I pass session variable in symfony model without using sfContext::getInstance() ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The recommended way is called dependency injection, and works like this: you create a
setUser()method in your model file, that saves the given parameter to a private property:This looks clumsy, because it is. But without you answering the question what are you trying to do? I cannot give an alternative.
Recommended articles: