Objects interacting with other Objects
Posted: Wed Oct 27, 2004 2:37 pm
Hello guys,
I have an interesting, although maybe not unusual, situation.
Being the organized guy I am, I really appreciate classes for their structure alone: I can look at the variable prepending a function and instantly tell the general idea of what that function is supposed to do. They are also nice for keeping unneeded functions and variables out of the way.
Anyway, with my current project, I have several classes, but the ones in question are:
class Sessions is responsible for creating, continuing, and destroying sessions.
The problem lies in the Sessions class communicating with the Accounts class: For instance, if a user returns and has a "remember me" cookie, then the Sessions class would need to utilize the Accounts class to determine the information to load into the current Session.
So, what is the best way to load a classes variable ($class = new Class()) into another class? I have several functions, and global $class in every function seems a bit excessive. Is there any way to load a global variable for an entire class? Or should I find a different way to structure this setup?
- Monkey
I have an interesting, although maybe not unusual, situation.
Being the organized guy I am, I really appreciate classes for their structure alone: I can look at the variable prepending a function and instantly tell the general idea of what that function is supposed to do. They are also nice for keeping unneeded functions and variables out of the way.
Anyway, with my current project, I have several classes, but the ones in question are:
- accounts.class
- sessions.class
class Sessions is responsible for creating, continuing, and destroying sessions.
The problem lies in the Sessions class communicating with the Accounts class: For instance, if a user returns and has a "remember me" cookie, then the Sessions class would need to utilize the Accounts class to determine the information to load into the current Session.
So, what is the best way to load a classes variable ($class = new Class()) into another class? I have several functions, and global $class in every function seems a bit excessive. Is there any way to load a global variable for an entire class? Or should I find a different way to structure this setup?
- Monkey