rdv: minor corrections following MR review

This commit is contained in:
nobohan 2021-07-23 10:14:20 +02:00
parent df7e76a2e7
commit cc3e7f54a7
5 changed files with 49 additions and 44 deletions

View File

@ -93,11 +93,11 @@ class CalendarController extends AbstractController
$view = 'ChillCalendarBundle:Calendar:listByAccompanyingCourse.html.twig'; $view = 'ChillCalendarBundle:Calendar:listByAccompanyingCourse.html.twig';
} }
return $this->render($view, array( return $this->render($view, [
'calendarItems' => $calendarItems, 'calendarItems' => $calendarItems,
'user' => $user, 'user' => $user,
'accompanyingCourse' => $accompanyingPeriod, 'accompanyingCourse' => $accompanyingPeriod,
)); ]);
} }
/** /**
@ -143,8 +143,11 @@ class CalendarController extends AbstractController
$params['id'] = $entity->getId(); $params['id'] = $entity->getId();
return $this->redirectToRoute('chill_calendar_calendar_show', $params); return $this->redirectToRoute('chill_calendar_calendar_show', $params);
} elseif ($form->isSubmitted() and !$form->isValid()) {
$this->addFlash('error', $this->get('translator')->trans('This form contains errors'));
} }
if ($view === null) { if ($view === null) {
throw $this->createNotFoundException('Template not found'); throw $this->createNotFoundException('Template not found');
} }
@ -194,12 +197,12 @@ class CalendarController extends AbstractController
throw $this->createNotFoundException('Template not found'); throw $this->createNotFoundException('Template not found');
} }
return $this->render($view, array( return $this->render($view, [
//'person' => $person, //'person' => $person,
'accompanyingCourse' => $accompanyingPeriod, 'accompanyingCourse' => $accompanyingPeriod,
'entity' => $entity, 'entity' => $entity,
//'delete_form' => $deleteForm->createView(), //'delete_form' => $deleteForm->createView(),
)); ]);
} }
@ -240,6 +243,8 @@ class CalendarController extends AbstractController
$params = $this->buildParamsToUrl($user, $accompanyingPeriod); $params = $this->buildParamsToUrl($user, $accompanyingPeriod);
$params['id'] = $id; $params['id'] = $id;
return $this->redirectToRoute('chill_activity_activity_show', $params); return $this->redirectToRoute('chill_activity_activity_show', $params);
} elseif ($form->isSubmitted() and !$form->isValid()) {
$this->addFlash('error', $this->get('translator')->trans('This form contains errors'));
} }
$deleteForm = $this->createDeleteForm($id, $user, $accompanyingPeriod); $deleteForm = $this->createDeleteForm($id, $user, $accompanyingPeriod);
@ -250,13 +255,13 @@ class CalendarController extends AbstractController
$entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); $entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
return $this->render($view, array( return $this->render($view, [
'entity' => $entity, 'entity' => $entity,
'form' => $form->createView(), 'form' => $form->createView(),
'delete_form' => $deleteForm->createView(), 'delete_form' => $deleteForm->createView(),
'accompanyingCourse' => $accompanyingPeriod, 'accompanyingCourse' => $accompanyingPeriod,
'entity_json' => $entity_array 'entity_json' => $entity_array
)); ]);
} }
/** /**
@ -290,10 +295,10 @@ class CalendarController extends AbstractController
if ($form->isValid()) { if ($form->isValid()) {
$this->logger->notice("A calendar event has been removed", array( $this->logger->notice("A calendar event has been removed", [
'by_user' => $this->getUser()->getUsername(), 'by_user' => $this->getUser()->getUsername(),
'calendar_id' => $entity->getId() 'calendar_id' => $entity->getId()
)); ]);
$em->remove($entity); $em->remove($entity);
$em->flush(); $em->flush();
@ -310,11 +315,11 @@ class CalendarController extends AbstractController
throw $this->createNotFoundException('Template not found'); throw $this->createNotFoundException('Template not found');
} }
return $this->render($view, array( return $this->render($view, [
'calendar' => $entity, 'calendar' => $entity,
'delete_form' => $form->createView(), 'delete_form' => $form->createView(),
'accompanyingCourse' => $accompanyingPeriod, 'accompanyingCourse' => $accompanyingPeriod,
)); ]);
} }
/** /**
@ -328,7 +333,7 @@ class CalendarController extends AbstractController
return $this->createFormBuilder() return $this->createFormBuilder()
->setAction($this->generateUrl('chill_calendar_calendar_delete', $params)) ->setAction($this->generateUrl('chill_calendar_calendar_delete', $params))
->setMethod('DELETE') ->setMethod('DELETE')
->add('submit', SubmitType::class, array('label' => 'Delete')) ->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm() ->getForm()
; ;
} }

View File

@ -20,15 +20,15 @@ class LoadCancelReason extends Fixture implements FixtureGroupInterface
return ['calendar']; return ['calendar'];
} }
public static $references = array(); public static $references = [];
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
$arr = array( $arr = [
array('name' => CancelReason::CANCELEDBY_USER), ['name' => CancelReason::CANCELEDBY_USER],
array('name' => CancelReason::CANCELEDBY_PERSON), ['name' => CancelReason::CANCELEDBY_PERSON],
array('name' => CancelReason::CANCELEDBY_DONOTCOUNT), ['name' => CancelReason::CANCELEDBY_DONOTCOUNT],
); ];
foreach ($arr as $a) { foreach ($arr as $a) {
print "Creating calendar cancel reason : " . $a['name'] . "\n"; print "Creating calendar cancel reason : " . $a['name'] . "\n";

View File

@ -20,14 +20,14 @@ class LoadInvite extends Fixture implements FixtureGroupInterface
return ['calendar']; return ['calendar'];
} }
public static $references = array(); public static $references = [];
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
$arr = array( $arr = [
array('name' => array('fr' => 'Rendez-vous décliné')), ['name' => ['fr' => 'Rendez-vous décliné']],
array('name' => array('fr' => 'Rendez-vous accepté')), ['name' => ['fr' => 'Rendez-vous accepté']],
); ];
foreach ($arr as $a) { foreach ($arr as $a) {
print "Creating calendar invite : " . $a['name']['fr'] . "\n"; print "Creating calendar invite : " . $a['name']['fr'] . "\n";

View File

@ -38,13 +38,13 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf
protected function preprendRoutes(ContainerBuilder $container) protected function preprendRoutes(ContainerBuilder $container)
{ {
$container->prependExtensionConfig('chill_main', array( $container->prependExtensionConfig('chill_main', [
'routing' => array( 'routing' => [
'resources' => array( 'resources' => [
'@ChillCalendarBundle/Resources/config/routing.yml' '@ChillCalendarBundle/Resources/config/routing.yml'
) ]
) ]
)); ]);
} }

View File

@ -44,42 +44,42 @@ class CalendarType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder $builder
->add('mainUser', EntityType::class, array( ->add('mainUser', EntityType::class, [
'required' => true, 'required' => true,
'class' => User::class, 'class' => User::class,
'choice_label' => function (User $entity) { 'choice_label' => function (User $entity) {
return $entity->getUsernameCanonical(); return $entity->getUsernameCanonical();
}, },
// TODO 'empty_data' => // TODO 'empty_data' =>
)) ])
->add('comment', CommentType::class, array( ->add('comment', CommentType::class, [
'required' => false 'required' => false
)) ])
->add('startDate', DateType::class, array( ->add('startDate', DateType::class, [
'required' => true, 'required' => true,
'input' => 'datetime_immutable', 'input' => 'datetime_immutable',
'widget' => 'single_text' 'widget' => 'single_text'
)) ])
->add('endDate', DateType::class, array( ->add('endDate', DateType::class, [
'required' => true, 'required' => true,
'input' => 'datetime_immutable', 'input' => 'datetime_immutable',
'widget' => 'single_text' 'widget' => 'single_text'
)) ])
->add('cancelReason', EntityType::class, array( ->add('cancelReason', EntityType::class, [
'required' => false, 'required' => false,
'class' => CancelReason::class, 'class' => CancelReason::class,
'choice_label' => function (CancelReason $entity) { 'choice_label' => function (CancelReason $entity) {
return $entity->getCanceledBy(); return $entity->getCanceledBy();
}, },
)) ])
->add('sendSMS', ChoiceType::class, array( ->add('sendSMS', ChoiceType::class, [
'required' => false, 'required' => false,
'choices' => array( 'choices' => [
'Oui' => true, 'Oui' => true,
'Non' => false 'Non' => false
), ],
'expanded' => true 'expanded' => true
)) ])
; ;
$builder->add('persons', HiddenType::class); $builder->add('persons', HiddenType::class);
@ -145,9 +145,9 @@ class CalendarType extends AbstractType
*/ */
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults(array( $resolver->setDefaults([
'data_class' => Calendar::class 'data_class' => Calendar::class
)); ]);
$resolver $resolver
->setRequired(['accompanyingPeriod']) ->setRequired(['accompanyingPeriod'])