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';
}
return $this->render($view, array(
return $this->render($view, [
'calendarItems' => $calendarItems,
'user' => $user,
'accompanyingCourse' => $accompanyingPeriod,
));
]);
}
/**
@ -143,8 +143,11 @@ class CalendarController extends AbstractController
$params['id'] = $entity->getId();
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) {
throw $this->createNotFoundException('Template not found');
}
@ -194,12 +197,12 @@ class CalendarController extends AbstractController
throw $this->createNotFoundException('Template not found');
}
return $this->render($view, array(
return $this->render($view, [
//'person' => $person,
'accompanyingCourse' => $accompanyingPeriod,
'entity' => $entity,
//'delete_form' => $deleteForm->createView(),
));
]);
}
@ -240,6 +243,8 @@ class CalendarController extends AbstractController
$params = $this->buildParamsToUrl($user, $accompanyingPeriod);
$params['id'] = $id;
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);
@ -250,13 +255,13 @@ class CalendarController extends AbstractController
$entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
return $this->render($view, array(
return $this->render($view, [
'entity' => $entity,
'form' => $form->createView(),
'delete_form' => $deleteForm->createView(),
'accompanyingCourse' => $accompanyingPeriod,
'entity_json' => $entity_array
));
]);
}
/**
@ -290,10 +295,10 @@ class CalendarController extends AbstractController
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(),
'calendar_id' => $entity->getId()
));
]);
$em->remove($entity);
$em->flush();
@ -310,11 +315,11 @@ class CalendarController extends AbstractController
throw $this->createNotFoundException('Template not found');
}
return $this->render($view, array(
return $this->render($view, [
'calendar' => $entity,
'delete_form' => $form->createView(),
'accompanyingCourse' => $accompanyingPeriod,
));
]);
}
/**
@ -328,7 +333,7 @@ class CalendarController extends AbstractController
return $this->createFormBuilder()
->setAction($this->generateUrl('chill_calendar_calendar_delete', $params))
->setMethod('DELETE')
->add('submit', SubmitType::class, array('label' => 'Delete'))
->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm()
;
}

View File

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

View File

@ -20,14 +20,14 @@ class LoadInvite extends Fixture implements FixtureGroupInterface
return ['calendar'];
}
public static $references = array();
public static $references = [];
public function load(ObjectManager $manager): void
{
$arr = array(
array('name' => array('fr' => 'Rendez-vous décliné')),
array('name' => array('fr' => 'Rendez-vous accepté')),
);
$arr = [
['name' => ['fr' => 'Rendez-vous décliné']],
['name' => ['fr' => 'Rendez-vous accepté']],
];
foreach ($arr as $a) {
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)
{
$container->prependExtensionConfig('chill_main', array(
'routing' => array(
'resources' => array(
$container->prependExtensionConfig('chill_main', [
'routing' => [
'resources' => [
'@ChillCalendarBundle/Resources/config/routing.yml'
)
)
));
]
]
]);
}

View File

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