Skip to content

Commit

Permalink
Use EntityManagerInterface instead of EntityManager (to support decor…
Browse files Browse the repository at this point in the history
…ators, etc)
  • Loading branch information
Chris Serino authored and lavoiesl committed Mar 23, 2015
1 parent f9ca27c commit 48ec281
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions lib/Doctrine/Common/DataFixtures/Executor/ORMExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Doctrine\Common\DataFixtures\Executor;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\Common\DataFixtures\Event\Listener\ORMReferenceListener;
use Doctrine\Common\DataFixtures\ReferenceRepository;
Expand All @@ -34,9 +34,9 @@ class ORMExecutor extends AbstractExecutor
/**
* Construct new fixtures loader instance.
*
* @param EntityManager $em EntityManager instance used for persistence.
* @param EntityManagerInterface $em EntityManagerInterface instance used for persistence.
*/
public function __construct(EntityManager $em, ORMPurger $purger = null)
public function __construct(EntityManagerInterface $em, ORMPurger $purger = null)
{
$this->em = $em;
if ($purger !== null) {
Expand All @@ -49,9 +49,9 @@ public function __construct(EntityManager $em, ORMPurger $purger = null)
}

/**
* Retrieve the EntityManager instance this executor instance is using.
* Retrieve the EntityManagerInterface instance this executor instance is using.
*
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getObjectManager()
{
Expand All @@ -75,7 +75,7 @@ public function setReferenceRepository(ReferenceRepository $referenceRepository)
public function execute(array $fixtures, $append = false)
{
$executor = $this;
$this->em->transactional(function(EntityManager $em) use ($executor, $fixtures, $append) {
$this->em->transactional(function(EntityManagerInterface $em) use ($executor, $fixtures, $append) {
if ($append === false) {
$executor->purge();
}
Expand Down
20 changes: 10 additions & 10 deletions lib/Doctrine/Common/DataFixtures/Purger/ORMPurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Doctrine\Common\DataFixtures\Purger;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Internal\CommitOrderCalculator;
use Doctrine\ORM\Mapping\ClassMetadata;

Expand All @@ -34,7 +34,7 @@ class ORMPurger implements PurgerInterface
const PURGE_MODE_DELETE = 1;
const PURGE_MODE_TRUNCATE = 2;

/** EntityManager instance used for persistence. */
/** EntityManagerInterface instance used for persistence. */
private $em;

/**
Expand All @@ -47,9 +47,9 @@ class ORMPurger implements PurgerInterface
/**
* Construct new purger instance.
*
* @param EntityManager $em EntityManager instance used for persistence.
* @param EntityManagerInterface $em EntityManagerInterface instance used for persistence.
*/
public function __construct(EntityManager $em = null)
public function __construct(EntityManagerInterface $em = null)
{
$this->em = $em;
}
Expand All @@ -76,19 +76,19 @@ public function getPurgeMode()
}

/**
* Set the EntityManager instance this purger instance should use.
* Set the EntityManagerInterface instance this purger instance should use.
*
* @param EntityManager $em
* @param EntityManagerInterface $em
*/
public function setEntityManager(EntityManager $em)
public function setEntityManager(EntityManagerInterface $em)
{
$this->em = $em;
}

/**
* Retrieve the EntityManager instance this purger instance is using.
* Retrieve the EntityManagerInterface instance this purger instance is using.
*
* @return \Doctrine\ORM\EntityManager
* @return \Doctrine\ORM\EntityManagerInterface
*/
public function getObjectManager()
{
Expand Down Expand Up @@ -136,7 +136,7 @@ public function purge()
}
}

private function getCommitOrder(EntityManager $em, array $classes)
private function getCommitOrder(EntityManagerInterface $em, array $classes)
{
$calc = new CommitOrderCalculator;

Expand Down

0 comments on commit 48ec281

Please sign in to comment.