ORMPurgerFactory.php 653 B

1234567891011121314151617181920
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\Bundle\FixturesBundle\Purger;
  4. use Doctrine\Common\DataFixtures\Purger\ORMPurger;
  5. use Doctrine\Common\DataFixtures\Purger\PurgerInterface;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. final class ORMPurgerFactory implements PurgerFactory
  8. {
  9. public function createForEntityManager(?string $emName, EntityManagerInterface $em, array $excluded = [], bool $purgeWithTruncate = false) : PurgerInterface
  10. {
  11. $purger = new ORMPurger($em, $excluded);
  12. $purger->setPurgeMode($purgeWithTruncate ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
  13. return $purger;
  14. }
  15. }