Let’s imagine I have controller where are a lot of methods that use the same model. Is it ok to do like this… http://codepad.org/bSSMFpzp
Before I did like I create new variable in each method… I just try to follow DRY principles. ))
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.
I don’t think it is the most helpful call, the factory() calls can be chained from so it can be pretty simple anyway. Additionally you don’t need to have the variables as object properties in the example code, you could be using $alln instead of $this->alln. Which I feel makes code more readable.
That being said, if you have a reason to make it an object property in the other actions, yes its okay to assign an object to the controller that you may use in multiple actions. You do have to be sure you’re not going to replace anything that is already in the parent class that you might replace.
So if you are just using the Controller provided by Kohana, then don’t use the variables request or response.