I'm currently using ZF2 as a library.
Currently, I'm pretty much cascading an injection of my database object into the controllers via the route. Obviously, had I started to use zend framework 2 in the first place, I would have stored the DB into an instance of ServiceManager and sent that through instead.
Anyway, I have a service class which is full of static method. These methods are basic, and all they do is report back information. They're pretty much brainless. A method I have: UserService::getCurrentUser()
is meant to return an object containing the current user information.
However, one problem I'm dealing with, is that inside this method, I'm doing this:
$user = new objects\user();
$user->setUserId(self::currentUserId());
$data = new \model\dao\users($database);
$user = $data->loadUser($user);
return $user;
I seem to now have a black hole in that I have no way of getting the $database, in this case, an instance of Zend\Db\Adapter
.
Any ideas how I can plug this hole?