mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
correct deprecated activity method
This commit is contained in:
parent
1bd6df7ce2
commit
e3040f4bfb
@ -384,8 +384,8 @@ final class ActivityController extends AbstractController
|
||||
|
||||
$form = $this->createForm(ActivityType::class, $entity, [
|
||||
'center' => $entity->getCenter(),
|
||||
'role' => new Role('CHILL_ACTIVITY_CREATE'),
|
||||
'activityType' => $entity->getType(),
|
||||
'role' => new Role('CHILL_ACTIVITY_CREATE'),
|
||||
'activityType' => $entity->getActivityType(),
|
||||
'accompanyingPeriod' => $accompanyingPeriod,
|
||||
])->handleRequest($request);
|
||||
|
||||
@ -482,10 +482,26 @@ final class ActivityController extends AbstractController
|
||||
throw $this->createNotFoundException('Unable to find Activity entity.');
|
||||
}
|
||||
|
||||
if (null !== $accompanyingPeriod) {
|
||||
// @TODO: Properties created dynamically.
|
||||
$entity->personsAssociated = $entity->getPersonsAssociated();
|
||||
$entity->personsNotAssociated = $entity->getPersonsNotAssociated();
|
||||
// TODO
|
||||
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity);
|
||||
|
||||
$form = $this->createForm(ActivityType::class, $entity, [
|
||||
'center' => $entity->getCenter(),
|
||||
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
|
||||
'activityType' => $entity->getActivityType(),
|
||||
'accompanyingPeriod' => $accompanyingPeriod,
|
||||
])->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->persist($entity);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')->trans('Success : activity updated!'));
|
||||
|
||||
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||
$params['id'] = $entity->getId();
|
||||
|
||||
return $this->redirectToRoute('chill_activity_activity_show', $params);
|
||||
}
|
||||
|
||||
// TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période
|
||||
@ -517,7 +533,59 @@ final class ActivityController extends AbstractController
|
||||
|
||||
private function buildParamsToUrl(?Person $person, ?AccompanyingPeriod $accompanyingPeriod): array
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
$params = [];
|
||||
=======
|
||||
$view = null;
|
||||
|
||||
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||
|
||||
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||
$view = 'ChillActivityBundle:Activity:confirm_deleteAccompanyingCourse.html.twig';
|
||||
} elseif ($person instanceof Person) {
|
||||
$view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig';
|
||||
}
|
||||
|
||||
$activity = $this->activityRepository->find($id);
|
||||
|
||||
if (!$activity) {
|
||||
throw $this->createNotFoundException('Unable to find Activity entity.');
|
||||
}
|
||||
|
||||
// TODO
|
||||
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
|
||||
|
||||
$form = $this->createDeleteForm($activity->getId(), $person, $accompanyingPeriod);
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$this->logger->notice("An activity has been removed", [
|
||||
'by_user' => $this->getUser()->getUsername(),
|
||||
'activity_id' => $activity->getId(),
|
||||
'person_id' => $activity->getPerson() ? $activity->getPerson()->getId() : null,
|
||||
'comment' => $activity->getComment()->getComment(),
|
||||
'scope_id' => $activity->getScope() ? $activity->getScope()->getId() : null,
|
||||
'reasons_ids' => $activity->getReasons()
|
||||
->map(
|
||||
static fn (ActivityReason $ar): int => $ar->getId()
|
||||
)
|
||||
->toArray(),
|
||||
'type_id' => $activity->getActivityType()->getId(),
|
||||
'duration' => $activity->getDurationTime() ? $activity->getDurationTime()->format('U') : null,
|
||||
'date' => $activity->getDate()->format('Y-m-d'),
|
||||
'attendee' => $activity->getAttendee()
|
||||
]);
|
||||
|
||||
$this->entityManager->remove($activity);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
->trans("The activity has been successfully removed."));
|
||||
|
||||
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||
>>>>>>> correct deprecated activity method
|
||||
|
||||
if (null !== $person) {
|
||||
$params['person_id'] = $person->getId();
|
||||
|
Loading…
x
Reference in New Issue
Block a user