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);
     $document->setDrop($drop);
     $em = $this->getDoctrine()->getManager();
     $em->persist($document);
     $em->flush();
     $event = new LogDocumentCreateEvent($dropzone, $drop, $document);
     $this->dispatch($event);
 }