I have a DAO, for example, for accessing database of tokens. Is it OK to use it co create and immediately persist new entities, like in the example below? (sample in PHP)
class TokenDao {
...
public function createToken($code) {
$token = new Token($code);
$this->entityManager->persist($token);
$this->entityManager->flush();
return $token;
}
}
It combines an object factory with DAO a bit. I think making separate object factory and dao (and probably wrapping into facade) is unnecessary overhead, but I'd like to hear from others if this isn't a bad practice.
I haven't found any positive or negative clues over articles about DAO pattern if this is ok or not.
Thanks for opinions/answers.
Aucun commentaire:
Enregistrer un commentaire