rdv: fullcalendar: save calendarRange id as an extended prop in the calendar entity

This commit is contained in:
nobohan
2021-08-18 15:54:35 +02:00
parent 07eb5c797a
commit a70d5cc263
6 changed files with 38 additions and 9 deletions

View File

@@ -15,6 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Chill\MainBundle\Form\Type\CommentType;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\CalendarBundle\Entity\CancelReason;
use Chill\CalendarBundle\Entity\Invite;
use Chill\MainBundle\Entity\User;
@@ -145,6 +146,24 @@ class CalendarType extends AbstractType
))
;
$builder->add('calendarRange', HiddenType::class);
$builder->get('calendarRange')
->addModelTransformer(new CallbackTransformer(
function (?CalendarRange $calendarRange): int {
if (NULL !== $calendarRange) {
$res = $calendarRange->getId();
} else {
$res = -1;
}
return $res;
},
function (?string $calendarRangeId): CalendarRange {
return $this->om->getRepository(CalendarRange::class)->findOneBy(['id' => (int) $calendarRangeId]);
}
))
;
// $builder->add('invites', HiddenType::class);
// $builder->get('invites')
// ->addModelTransformer(new CallbackTransformer(