private function createDocument(Dropzone $dropzone, Drop $drop, $form, $documentType) { $document = new Document(); $document->setType($documentType); $node = null; if ($documentType == 'url') { $data = $form->getData(); $url = $data['document']; $document->setUrl($url); } else { if ($documentType == 'file') { $file = $form['document']; $node = $this->createFile($dropzone, $drop, $file->getData()); } else { if ($documentType == 'text') { $data = $form->getData(); $node = $this->createText($dropzone, $drop, $data['document']); } else { if ($documentType == 'resource') { $data = $form->getData(); $node = $this->createResource($dropzone, $drop, $data['document']); } else { throw new \ErrorException(); } } } } $document->setResourceNode($node); // #19. Ajout de la valorisation de la Date. InnovaERV. $document->setDocumentDate(new \DateTime()); $document->setDrop($drop); $em = $this->getDoctrine()->getManager(); $em->persist($document); $em->flush(); $event = new LogDocumentCreateEvent($dropzone, $drop, $document); $this->dispatch($event); }
private function createDocument(Dropzone $dropzone, Drop $drop, $form, $documentType) { $dropzoneVoter = $this->get('innova.manager.dropzone_voter'); $document = new Document(); $document->setType($documentType); $node = null; if ($documentType == 'url') { $data = $form->getData(); $url = $data['document']; $document->setUrl($url); } else { if ($documentType == 'file') { $file = $form['document']; $node = $this->createFile($dropzone, $drop, $file->getData()); } else { if ($documentType == 'text') { $data = $form->getData(); $node = $this->createText($dropzone, $drop, $data['document']); } else { if ($documentType == 'resource') { $data = $form->getData(); $node = $this->createResource($dropzone, $drop, $data['document']); } else { throw new \ErrorException(); } } } } $document->setResourceNode($node); // #19. Ajout de la valorisation de la Date. InnovaERV. $document->setDocumentDate(new \DateTime()); $sender = $this->get('security.token_storage')->getToken()->getUser(); $canEdit = $dropzoneVoter->checkEditRight($dropzone); if ($canEdit) { $document->setValidate(true); } $document->setDrop($drop); $document->setSender($sender); // #126. Ajout de la valorisation du titre du document. InnovaERV. if ($documentType == 'text') { $document->setTitle($data['title']); } $em = $this->getDoctrine()->getManager(); $em->persist($document); $em->flush(); $event = new LogDocumentCreateEvent($dropzone, $drop, $document); $this->dispatch($event); return $document; }
private function createDocument(Dropzone $dropzone, Drop $drop, $form, $documentType) { $document = new Document(); $document->setType($documentType); $node = null; if ($documentType === 'url') { $data = $form->getData(); $url = $data['document']; $document->setUrl($url); } elseif ($documentType === 'file') { $file = $form['document']; $node = $this->createFile($dropzone, $drop, $file->getData()); } elseif ($documentType === 'text') { $data = $form->getData(); // Maintenant, on insère le TITRE qui est saisi. $node = $this->createText($dropzone, $drop, $data['document'], $data['title']); } elseif ($documentType === 'resource') { $data = $form->getData(); $node = $this->createResource($dropzone, $drop, $data['document']); } else { throw new \ErrorException(); } $document->setResourceNode($node); // Ajout de la valorisation de la Date. InnovaERV. $document->setDocumentDate(new \DateTime()); $sender = $this->get('security.token_storage')->getToken()->getUser(); $document->setDrop($drop); $document->setSender($sender); // Ajout de la valorisation du titre du document. InnovaERV. if ($documentType === 'text') { $document->setTitle($data['title']); } $em = $this->getDoctrine()->getManager(); $em->persist($document); $em->flush(); $event = new LogDocumentCreateEvent($dropzone, $drop, $document); $this->dispatch($event); return $document; }