Skip to content

Commit

Permalink
Merge pull request #347 from kissifrot/feature/allow-custom-ormpurger
Browse files Browse the repository at this point in the history
Allow Custom ORMPurger
  • Loading branch information
alcaeus committed Apr 7, 2020
2 parents 265b209 + d53b8d6 commit 9e2a625
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/Common/DataFixtures/Executor/ORMExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Doctrine\Common\DataFixtures\Executor;

use Doctrine\Common\DataFixtures\Event\Listener\ORMReferenceListener;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\Common\DataFixtures\Purger\ORMPurgerInterface;
use Doctrine\Common\DataFixtures\ReferenceRepository;
use Doctrine\ORM\EntityManagerInterface;

Expand All @@ -22,7 +22,7 @@ class ORMExecutor extends AbstractExecutor
*
* @param EntityManagerInterface $em EntityManagerInterface instance used for persistence.
*/
public function __construct(EntityManagerInterface $em, ?ORMPurger $purger = null)
public function __construct(EntityManagerInterface $em, ?ORMPurgerInterface $purger = null)
{
$this->em = $em;
if ($purger !== null) {
Expand Down
6 changes: 2 additions & 4 deletions lib/Doctrine/Common/DataFixtures/Purger/ORMPurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Class responsible for purging databases of data before reloading data fixtures.
*/
class ORMPurger implements PurgerInterface
class ORMPurger implements PurgerInterface, ORMPurgerInterface
{
public const PURGE_MODE_DELETE = 1;
public const PURGE_MODE_TRUNCATE = 2;
Expand Down Expand Up @@ -76,9 +76,7 @@ public function getPurgeMode()
return $this->purgeMode;
}

/**
* Set the EntityManagerInterface instance this purger instance should use.
*/
/** @inheritDoc */
public function setEntityManager(EntityManagerInterface $em)
{
$this->em = $em;
Expand Down
20 changes: 20 additions & 0 deletions lib/Doctrine/Common/DataFixtures/Purger/ORMPurgerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Doctrine\Common\DataFixtures\Purger;

use Doctrine\ORM\EntityManagerInterface;

/**
* ORMPurgerInterface
*/
interface ORMPurgerInterface extends PurgerInterface
{
/**
* Set the EntityManagerInterface instance this purger instance should use.
*
* @return void
*/
public function setEntityManager(EntityManagerInterface $em);
}
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming">
<exclude-pattern>lib/Doctrine/Common/DataFixtures/DependentFixtureInterface.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/Common/DataFixtures/FixtureInterface.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/Common/DataFixtures/Purger/ORMPurgerInterface.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/Common/DataFixtures/Purger/PurgerInterface.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/Common/DataFixtures/OrderedFixtureInterface.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/Common/DataFixtures/SharedFixtureInterface.php</exclude-pattern>
Expand Down

0 comments on commit 9e2a625

Please sign in to comment.