Last active
December 17, 2015 14:49
-
-
Save drgomesp/5627112 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class YourDomainClass | |
{ | |
protected $manager; | |
public function __construct(PersistenceManager $manager) | |
{ | |
$this->manager = $manager; | |
} | |
public function doSomething() | |
{ | |
$entity = new Entity(); | |
// do something | |
$this->manager->persist($entity); | |
} | |
} | |
interface PersistenceManager | |
{ | |
function persist($entity); | |
} | |
class DoctrineManager implements PersistenceManager | |
{ | |
protected $em; | |
public function __construct(EntityManager $em) | |
{ | |
$this->em = $em; | |
} | |
public function persist($entity) | |
{ | |
$this->em->persist($entity); | |
$this->flush(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment