From faffdee1ab2db18e7d22c6740ea543496e789867 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 3 Jul 2015 09:40:30 +0200 Subject: [PATCH] Integration code generated --- Controller/ActivityController.php | 18 +++++++++++++----- Entity/Activity.php | 2 +- Form/ActivityType.php | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Controller/ActivityController.php b/Controller/ActivityController.php index 0c89842db..0c4f12793 100644 --- a/Controller/ActivityController.php +++ b/Controller/ActivityController.php @@ -68,7 +68,9 @@ class ActivityController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $entity->getId()))); + return $this->redirect( + $this->generateUrl('chill_activity_activity_show', + array('id' => $entity->getId(), 'person_id' => $person_id))); } return $this->render('ChillActivityBundle:Activity:new.html.twig', array( @@ -107,6 +109,9 @@ class ActivityController extends Controller $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $entity = new Activity(); + $entity->setUser($this->get('security.context')->getToken()->getUser()); + $entity->setDate(new \DateTime('now')); + $form = $this->createCreateForm($entity, $person); return $this->render('ChillActivityBundle:Activity:new.html.twig', array( @@ -120,9 +125,10 @@ class ActivityController extends Controller * Finds and displays a Activity entity. * */ - public function showAction($id) + public function showAction($person_id, $id) { $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $entity = $em->getRepository('ChillActivityBundle:Activity')->find($id); @@ -130,7 +136,7 @@ class ActivityController extends Controller throw $this->createNotFoundException('Unable to find Activity entity.'); } - $deleteForm = $this->createDeleteForm($id); + $deleteForm = $this->createDeleteForm($id, $person); return $this->render('ChillActivityBundle:Activity:show.html.twig', array( 'entity' => $entity, @@ -243,10 +249,12 @@ class ActivityController extends Controller * * @return \Symfony\Component\Form\Form The form */ - private function createDeleteForm($id) + private function createDeleteForm($id, $person) { return $this->createFormBuilder() - ->setAction($this->generateUrl('chill_activity_activity_delete', array('id' => $id))) + ->setAction($this->generateUrl( + 'chill_activity_activity_delete', + array('id' => $id, 'person_id' => $person->getId()))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() diff --git a/Entity/Activity.php b/Entity/Activity.php index e4662983d..084f1a067 100644 --- a/Entity/Activity.php +++ b/Entity/Activity.php @@ -99,7 +99,7 @@ class Activity * * @return Activity */ - public function setUserr(User $user) + public function setUser(User $user) { $this->user = $user; diff --git a/Form/ActivityType.php b/Form/ActivityType.php index 80be41de9..04237bdc3 100644 --- a/Form/ActivityType.php +++ b/Form/ActivityType.php @@ -15,10 +15,10 @@ class ActivityType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('date') + ->add('date', 'date', array('widget' => 'single_text', 'format' => 'dd-MM-yyyy')) ->add('durationTime') ->add('remark') - ->add('attendee') + ->add('attendee', 'checkbox', array('required' => false)) ->add('user') //->add('scope') //->add('reason')