Model/DocumentService.php
/**
     * Save the document to the database and trigger the upload
     * warning : the persist action trigger the upload.
     * @param  Document     $document
     * @param  UploadedFile $file
     * @return Document                 The document saved with non null id.
     * @throws DocumentException  If the validation fails
     */
Save the document to the database and trigger the upload
warning : the persist action trigger the upload.
@param  Document     $document
@param  UploadedFile $file
@return Document                 The document saved with non null id.
@throws DocumentException  If the validation fails
Save the document to the database and trigger the upload warning : the persist action trigger the upload . @param Document $document @param UploadedFile $file @return Document The document saved with non null id . @throws DocumentException If the validation fails
public function createDocument(Document $document, UploadedFile $file = null)
    {
        if( ! is_null($file) ){
            $document->setFile($file);
            $this->setMetadata($document, $file);
            $this->validate($document);
        }
        $this->em->persist($document);
        $this->em->flush();
        return $document;
    }
public function createDocument ( Document $ document , UploadedFile $ file = null ) { if ( ! is_null ( $ file ) ) { $ document -> setFile ( $ file ) ; $ this -> setMetadata ( $ document , $ file ) ; $ this -> validate ( $ document ) ; } $ this -> em -> persist ( $ document ) ; $ this -> em -> flush ( ) ; return $ document ; }
Save the document to the database and trigger the upload
 warning : the persist action trigger the upload.
Save the document to the database and trigger the upload warning : the persist action trigger the upload .