diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseDuplicateController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseDuplicateController.php new file mode 100644 index 000000000..129109634 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseDuplicateController.php @@ -0,0 +1,55 @@ +security->isGranted(AccompanyingCourseDocumentVoter::SEE, $document)) { + throw new AccessDeniedHttpException('not allowed to see this document'); + } + + if (!$this->security->isGranted(AccompanyingCourseDocumentVoter::CREATE, $document->getCourse())) { + throw new AccessDeniedHttpException('not allowed to create this document'); + } + + $duplicated = $this->documentWorkflowDuplicator->duplicate($document); + $this->entityManager->persist($duplicated); + $this->entityManager->flush(); + + return new RedirectResponse( + $this->urlGenerator->generate('accompanying_course_document_edit', ['id' => $duplicated->getId(), 'course' => $duplicated->getCourse()->getId()]) + ); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig index 2a3592d73..7ec761464 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig @@ -73,8 +73,15 @@