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()]) ); } }