mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
rdv: add new rdv form
This commit is contained in:
@@ -156,17 +156,6 @@ class CalendarController extends AbstractController
|
||||
// $view = 'ChillCalendarBundle:Calendar:newUser.html.twig';
|
||||
// }
|
||||
|
||||
// $activityType_id = $request->get('activityType_id', 0);
|
||||
// $activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
|
||||
// ->find($activityType_id);
|
||||
|
||||
// if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType ||
|
||||
// !$activityType->isActive()) {
|
||||
|
||||
// $params = $this->buildParamsToUrl($user, $accompanyingPeriod);
|
||||
// return $this->redirectToRoute('chill_activity_activity_select_type', $params);
|
||||
// }
|
||||
|
||||
$entity = new Calendar();
|
||||
$entity->setUser($this->getUser());
|
||||
|
||||
@@ -181,28 +170,25 @@ class CalendarController extends AbstractController
|
||||
// $entity->setType($activityType);
|
||||
// $entity->setDate(new \DateTime('now'));
|
||||
|
||||
// $form = $this->createForm(ActivityType::class, $entity, [
|
||||
// 'center' => $entity->getCenter(),
|
||||
// 'role' => new Role('CHILL_ACTIVITY_CREATE'),
|
||||
// 'activityType' => $entity->getType(),
|
||||
// 'accompanyingPeriod' => $accompanyingPeriod,
|
||||
// ])->handleRequest($request);
|
||||
$form = $this->createForm(CalendarType::class, $entity, [
|
||||
'accompanyingPeriod' => $accompanyingPeriod,
|
||||
])->handleRequest($request);
|
||||
|
||||
// if ($form->isSubmitted() && $form->isValid()) {
|
||||
// $em->persist($entity);
|
||||
// $em->flush();
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
// $this->addFlash('success', $this->get('translator')->trans('Success : activity created!'));
|
||||
$this->addFlash('success', $this->get('translator')->trans('Success : calendar item created!'));
|
||||
|
||||
// $params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||
// $params['id'] = $entity->getId();
|
||||
$params = $this->buildParamsToUrl($user, $accompanyingPeriod); //TODO useful?
|
||||
$params['id'] = $entity->getId();
|
||||
|
||||
// return $this->redirectToRoute('chill_activity_activity_show', $params);
|
||||
// }
|
||||
return $this->redirectToRoute('chill_calendar_calendar_show', $params);
|
||||
}
|
||||
|
||||
// if ($view === null) {
|
||||
// throw $this->createNotFoundException('Template not found');
|
||||
// }
|
||||
if ($view === null) {
|
||||
throw $this->createNotFoundException('Template not found');
|
||||
}
|
||||
|
||||
// $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
||||
|
||||
@@ -210,7 +196,7 @@ class CalendarController extends AbstractController
|
||||
'user' => $user,
|
||||
'accompanyingCourse' => $accompanyingPeriod,
|
||||
'entity' => $entity,
|
||||
// 'form' => $form->createView(),
|
||||
'form' => $form->createView(),
|
||||
//'activity_json' => $calendar_array
|
||||
]);
|
||||
}
|
||||
@@ -456,20 +442,20 @@ class CalendarController extends AbstractController
|
||||
];
|
||||
}
|
||||
|
||||
// private function buildParamsToUrl(
|
||||
// ?Person $person,
|
||||
// ?AccompanyingPeriod $accompanyingPeriod
|
||||
// ): array {
|
||||
// $params = [];
|
||||
private function buildParamsToUrl(
|
||||
?User $user,
|
||||
?AccompanyingPeriod $accompanyingPeriod
|
||||
): array {
|
||||
$params = [];
|
||||
|
||||
// if ($person) {
|
||||
// $params['person_id'] = $person->getId();
|
||||
// }
|
||||
if ($user) {
|
||||
$params['user_id'] = $user->getId();
|
||||
}
|
||||
|
||||
// if ($accompanyingPeriod) {
|
||||
// $params['accompanying_period_id'] = $accompanyingPeriod->getId();
|
||||
// }
|
||||
if ($accompanyingPeriod) {
|
||||
$params['accompanying_period_id'] = $accompanyingPeriod->getId();
|
||||
}
|
||||
|
||||
// return $params;
|
||||
// }
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user