mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix LoadInvite fixture (CalendarBundle)
This commit is contained in:
parent
4370349f10
commit
5ee0ab5ab8
@ -12,6 +12,8 @@ declare(strict_types=1);
|
|||||||
namespace Chill\CalendarBundle\DataFixtures\ORM;
|
namespace Chill\CalendarBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\CalendarBundle\Entity\Invite;
|
use Chill\CalendarBundle\Entity\Invite;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
@ -33,14 +35,21 @@ class LoadInvite extends Fixture implements FixtureGroupInterface
|
|||||||
public function load(ObjectManager $manager): void
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
$arr = [
|
$arr = [
|
||||||
['name' => ['fr' => 'Rendez-vous décliné']],
|
[
|
||||||
['name' => ['fr' => 'Rendez-vous accepté']],
|
'name' => ['fr' => 'Rendez-vous décliné'],
|
||||||
|
'status' => 'declined'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => ['fr' => 'Rendez-vous accepté'],
|
||||||
|
'status' => 'accepted'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($arr as $a) {
|
foreach ($arr as $a) {
|
||||||
echo 'Creating calendar invite : ' . $a['name']['fr'] . "\n";
|
echo 'Creating calendar invite : ' . $a['name']['fr'] . "\n";
|
||||||
$invite = (new Invite())
|
$invite = (new Invite())
|
||||||
->setStatus($a['name']);
|
->setStatus($a['status'])
|
||||||
|
->setUser($this->getRandomUser());
|
||||||
$manager->persist($invite);
|
$manager->persist($invite);
|
||||||
$reference = 'Invite_' . $a['name']['fr'];
|
$reference = 'Invite_' . $a['name']['fr'];
|
||||||
$this->addReference($reference, $invite);
|
$this->addReference($reference, $invite);
|
||||||
@ -49,4 +58,11 @@ class LoadInvite extends Fixture implements FixtureGroupInterface
|
|||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getRandomUser(): User
|
||||||
|
{
|
||||||
|
$userRef = array_rand(LoadUsers::$refs);
|
||||||
|
|
||||||
|
return $this->getReference($userRef);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user