56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\DataFixtures;
|
|
|
|
use App\Entity\Don;
|
|
use App\Repository\DonCatRepository;
|
|
use App\Repository\PatientRepository;
|
|
use Doctrine\Persistence\ObjectManager;
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
|
|
|
class DonFixtures extends Fixture implements DependentFixtureInterface
|
|
{
|
|
protected PatientRepository $patientRepository;
|
|
protected DonCatRepository $donCatRepository;
|
|
public function __construct(PatientRepository $patientRepository, DonCatRepository $donCatRepository)
|
|
{
|
|
$this->patientRepository = $patientRepository;
|
|
$this->donCatRepository = $donCatRepository;
|
|
}
|
|
public function load(ObjectManager $manager): void
|
|
{
|
|
$donneur = $this->patientRepository->findOneBy(['lastname'=>'Durand']);
|
|
$donCat = $this->donCatRepository->findBy([], ['name'=>'ASC'], 1)[0];
|
|
$donneur = (new Don())
|
|
->setCodeBarre('12345678912')
|
|
->setDonCat($donCat)
|
|
->setNbreTube(5)
|
|
->setDonneur($donneur)
|
|
;
|
|
$manager->persist($donneur);
|
|
$manager->flush();
|
|
|
|
|
|
$donneur = $this->patientRepository->findOneBy(['lastname'=>'Gauthier']);
|
|
$donCat = $this->donCatRepository->findBy([], ['name'=>'ASC'], 1)[0];
|
|
$donneur = (new Don())
|
|
->setCodeBarre('12345678913')
|
|
->setDonCat($donCat)
|
|
->setNbreTube(6)
|
|
->setDonneur($donneur)
|
|
;
|
|
$manager->persist($donneur);
|
|
$manager->flush();
|
|
}
|
|
|
|
|
|
public function getDependencies()
|
|
{
|
|
return [
|
|
DonCatFixtures::class,
|
|
PatientFixtures::class
|
|
];
|
|
}
|
|
}
|