コード例 #1
0
 /**
  * @DI\Observe("copy_icap_dropzone")
  *
  * @param CopyResourceEvent $event
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     /** @var Dropzone $resource */
     $resource = $event->getResource();
     $newDropzone = new Dropzone();
     $newDropzone->setName($resource->getName());
     $newDropzone->setAllowCommentInCorrection($resource->getAllowCommentInCorrection());
     $newDropzone->setAllowRichText($resource->getAllowRichText());
     $newDropzone->setAllowUpload($resource->getAllowUpload());
     $newDropzone->setAllowUrl($resource->getAllowUrl());
     $newDropzone->setAllowWorkspaceResource($resource->getAllowWorkspaceResource());
     $newDropzone->setDisplayNotationMessageToLearners($resource->getDisplayNotationMessageToLearners());
     $newDropzone->setDisplayNotationToLearners($resource->getDisplayNotationToLearners());
     $newDropzone->setEditionState($resource->getEditionState());
     $newDropzone->setEndAllowDrop($resource->getEndAllowDrop());
     $newDropzone->setEndReview($resource->getEndReview());
     $newDropzone->setExpectedTotalCorrection($resource->getExpectedTotalCorrection());
     $newDropzone->setInstruction($resource->getInstruction());
     $newDropzone->setManualPlanning($resource->getManualPlanning());
     $newDropzone->setManualState($resource->getManualState());
     $newDropzone->setMinimumScoreToPass($resource->getMinimumScoreToPass());
     $newDropzone->setPeerReview($resource->getPeerReview());
     $newDropzone->setStartAllowDrop($resource->getStartAllowDrop());
     $newDropzone->setStartReview($resource->getStartReview());
     $newDropzone->setTotalCriteriaColumn($resource->getTotalCriteriaColumn());
     $oldCriteria = $resource->getPeerReviewCriteria();
     foreach ($oldCriteria as $oldCriterion) {
         $newCriterion = new Criterion();
         $newCriterion->setInstruction($oldCriterion->getInstruction());
         $newDropzone->addCriterion($newCriterion);
     }
     $em->persist($newDropzone);
     $event->setCopy($newDropzone);
     $event->stopPropagation();
 }