getAccompanyingPeriodWorkEvaluation()->getAccompanyingPeriodWork(); if (!$this->security->isGranted(AccompanyingPeriodWorkVoter::UPDATE, $work)) { throw new AccessDeniedHttpException('not allowed to edit this accompanying period work'); } $duplicatedDocument = $this->duplicator->duplicate($document); $this->entityManager->persist($duplicatedDocument); $this->entityManager->persist($duplicatedDocument->getStoredObject()); $this->entityManager->flush(); return new JsonResponse( $this->serializer->serialize($duplicatedDocument, 'json', [AbstractNormalizer::GROUPS => ['read']]), json: true ); } }