I understand the importance of Injection Dependency and its role in unit testing, so the following problem gives me a pause:
In one area where I cannot use Singleton, the Identity Map / Unit of Work template is used (which contains tabs in the state of the domain object).
class Monitor{
static $members = array();
static $dirty = array();
static $clean = array();
}
class Mapper{
public function find($id){
if(isset(Monitor::members[$id]){
return Monitor::members[$id];
}
$values = $this->selectStmt($id);
$Object = new Object($values);
Monitor::new[$id]=$Object
return $Object;
}
$User = $UserMapper->find(1);
$User->changePropertyX();
$UserMapper->save($User);
$User->save();
$User->getBlogPosts();
$UserPosts = $UserMapper->getBlogPosts();
$User->setPosts($UserPosts);
Any tips on how you could handle this situation?
I would be sorry to transfer / generate instances of access to the map / database to the domain object itself to satisfy the DI - At the same time, avoiding this, you get a lot of calls inside the domain object for external static methods.
, , "" , . , , . Active Record - - .