A smart factory class
Posted: Sun Aug 27, 2006 3:45 pm
Smart factory class. I want to build a smart user class based on the factory model. But i have some troubles grasping it, basicly i want to do something like this:
The class will then return different classes according to the users permissions and functions and such. Is it possible to do something like this?
Thanks.
Code: Select all
class bla {
function bla()
{
$this->lol();
}
function ()
{
echo "Yup!";
}
function ly()
{
echo "Yip!";
}
}
class userFactory {
private $userID;
function userFactory($userID)
{
$waa = new bla();
return $waa;
}
}
try {
$user = new userFactory(1);
$user->lolly(); //Error
} catch (Exception $e) {
echo $e->getMessage();
}Thanks.