Pass class as second parameter to getReference() fixture method

This commit is contained in:
2024-11-28 13:28:52 +01:00
parent 19e6ceba28
commit f820273dd7
27 changed files with 94 additions and 59 deletions

View File

@@ -14,6 +14,7 @@ namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadCenters;
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\PostalCode;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\Bundle\FixturesBundle\Fixture;
@@ -70,10 +71,10 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface
$number = random_int(1, \count($references));
if (1 === $number) {
yield $this->getReference($references[array_rand($references)], null);
yield $this->getReference($references[array_rand($references)], Center::class);
} else {
foreach (array_rand($references, $number) as $index) {
yield $this->getReference($references[$index], null);
yield $this->getReference($references[$index], Center::class);
}
}
}
@@ -82,7 +83,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface
{
$ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)];
return $this->getReference($ref, null);
return $this->getReference($ref, PostalCode::class);
}
private function getThirdParties(): ObjectSet