php - Should an object being created by a factory method accept constructor arguments? -


i'm using factory pattern create users i'm having problem constructor issue.

i have following factory:

class userfactory {  public function factorymethod(user $user_type) {      $user = new $user_type($db);      return $user;  }  } 

i instantiate class follows:

$user = new userfactory(); $user = $user->factorymethod(new admin()); 

the issue is, need pass $db parameter new admin() call can't find way of doing or if it's possible.

have overlooked simple or not possible?


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -