mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
accompanyingPeriodWork: add action in controller
This commit is contained in:
parent
0299500cad
commit
e195434bf4
@ -11,7 +11,9 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Symfony\Component\Form\Form;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
class AccompanyingCourseWorkController extends AbstractController
|
class AccompanyingCourseWorkController extends AbstractController
|
||||||
{
|
{
|
||||||
@ -106,4 +108,83 @@ class AccompanyingCourseWorkController extends AbstractController
|
|||||||
'paginator' => $paginator
|
'paginator' => $paginator
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route(
|
||||||
|
* "{_locale}/person/accompanying-period/work/{id}/delete",
|
||||||
|
* name="chill_person_accompanying_period_work_delete",
|
||||||
|
* methods={"GET"}
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function deleteWork(AccompanyingPeriodWork $work): Response
|
||||||
|
{
|
||||||
|
// TODO ACL
|
||||||
|
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
dump($work);
|
||||||
|
// [$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
|
|
||||||
|
// /* @var $activity Activity */
|
||||||
|
// $activity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
||||||
|
|
||||||
|
// if (!$activity) {
|
||||||
|
// throw $this->createNotFoundException('Unable to find Activity entity.');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
|
||||||
|
|
||||||
|
$form = $this->createDeleteForm($work->getId());
|
||||||
|
|
||||||
|
// if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||||
|
// $form->handleRequest($request);
|
||||||
|
|
||||||
|
// if ($form->isValid()) {
|
||||||
|
|
||||||
|
// // $this->logger->notice("An activity has been removed", array(
|
||||||
|
// // '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(function ($ar) { return $ar->getId(); })
|
||||||
|
// // ->toArray(),
|
||||||
|
// // 'type_id' => $activity->getType()->getId(),
|
||||||
|
// // 'duration' => $activity->getDurationTime() ? $activity->getDurationTime()->format('U') : null,
|
||||||
|
// // 'date' => $activity->getDate()->format('Y-m-d'),
|
||||||
|
// // 'attendee' => $activity->getAttendee()
|
||||||
|
// // )); //TODO
|
||||||
|
|
||||||
|
// $em->remove($work);
|
||||||
|
// $em->flush();
|
||||||
|
|
||||||
|
// // $this->addFlash('success', $this->get('translator')
|
||||||
|
// // ->trans("The activity has been successfully removed."));
|
||||||
|
|
||||||
|
// // $params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||||
|
// // return $this->redirectToRoute('chill_activity_activity_list', $params);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
return $this->render('@ChillPerson/AccompanyingCourseWork/delete.html.twig', array(
|
||||||
|
'work' => $work,
|
||||||
|
'delete_form' => $form->createView()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createDeleteForm(int $id): Form
|
||||||
|
{
|
||||||
|
$params['id'] = $id;
|
||||||
|
|
||||||
|
return $this->createFormBuilder()
|
||||||
|
->setAction($this->generateUrl('chill_person_accompanying_period_work_delete', $params))
|
||||||
|
->setMethod('DELETE')
|
||||||
|
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
||||||
|
->getForm()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user