userRepository = $userRepository; } public static function getGroups(): array { return ['calendar']; } public function getOrder(): int { return 40003; } public function load(ObjectManager $manager): void { $arr = range(-50, 50); echo "Creating calendar range ('plage de disponibilités')\n"; $users = $this->userRepository->findAll(); $location = (new Location()) ->setAddress($address = new Address()) ->setName('Centre A') ->setEmail('centreA@test.chill.social') ->setLocationType($type = new LocationType()) ->setPhonenumber1(PhoneNumberUtil::getInstance()->parse('+3287653812')); $type->setTitle(['fr' => 'Service']); $address->setStreet('Rue des Épaules')->setStreetNumber('14') ->setPostcode($postCode = new PostalCode()); $postCode->setCode('4145')->setName('Houte-Si-Plout')->setCountry( ($country = new Country())->setName(['fr' => 'Pays'])->setCountryCode('ZZ') ); $manager->persist($country); $manager->persist($postCode); $manager->persist($address); $manager->persist($type); $manager->persist($location); $days = [ '2021-08-23', '2021-08-24', '2021-08-25', '2021-08-26', '2021-08-30', '2021-08-31', '2021-09-01', '2021-09-02', (new DateTimeImmutable('tomorrow'))->format('Y-m-d'), (new DateTimeImmutable('today'))->format('Y-m-d'), ]; $hours = [ '10:00:00', '11:30:00', '13:30:00', '15:00:00', ]; foreach ($users as $u) { foreach ($days as $d) { foreach ($hours as $h) { $event = $d . ' ' . $h; $startEvent = new DateTimeImmutable($event); $endEvent = new DateTimeImmutable($event . ' + 1 hours'); $calendarRange = (new CalendarRange()) ->setUser($u) ->setStartDate($startEvent) ->setEndDate($endEvent) ->setLocation($location); $manager->persist($calendarRange); } } } $manager->flush(); } }