Skip to content

Instantly share code, notes, and snippets.

@drgomesp
Last active December 17, 2015 14:49
Show Gist options
  • Save drgomesp/5627112 to your computer and use it in GitHub Desktop.
Save drgomesp/5627112 to your computer and use it in GitHub Desktop.
<?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