plugin/drop-zone/Controller/API/DropController.php
public function addDocumentAction(Drop $drop, $type, User $user, Request $request)
    {
        $dropzone = $drop->getDropzone();
        $this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true);
        $this->checkDropEdition($drop, $user);
        $documents = [];

        try {
            if (!$drop->isFinished()) {
                switch ($type) {
                    case Document::DOCUMENT_TYPE_FILE:
                        $files = $request->files->all();
                        $documents = $this->manager->createFilesDocuments($drop, $user, $files);
                        break;
                    case Document::DOCUMENT_TYPE_TEXT:
                    case Document::DOCUMENT_TYPE_URL:
                    case Document::DOCUMENT_TYPE_RESOURCE:
                        $uuid = $request->request->get('dropData', false);
                        $document = $this->manager->createDocument($drop, $user, $type, $uuid);
                        $documents[] = $this->manager->serializeDocument($document);
                        break;
                }
                $progression = $dropzone->isPeerReview() ? 0 : 50;
                $this->manager->updateDropProgression($dropzone, $drop, $progression);
            }

            return new JsonResponse($documents);
        } catch (\Exception $e) {
            return new JsonResponse($e->getMessage(), 422);
        }
    }
public function addDocumentAction(Drop $drop, $type, User $user, Request $request)
    {
        $dropzone = $drop->getDropzone();
        $this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true);
        $this->checkDropEdition($drop, $user);
        $documents = [];

        try {
            if (!$drop->isFinished()) {
                switch ($type) {
                    case Document::DOCUMENT_TYPE_FILE:
                        $files = $request->files->all();
                        $documents = $this->manager->createFilesDocuments($drop, $user, $files);
                        break;
                    case Document::DOCUMENT_TYPE_TEXT:
                    case Document::DOCUMENT_TYPE_URL:
                    case Document::DOCUMENT_TYPE_RESOURCE:
                        $uuid = $request->request->get('dropData', false);
                        $document = $this->manager->createDocument($drop, $user, $type, $uuid);
                        $documents[] = $this->manager->serializeDocument($document);
                        break;
                }
                $progression = $dropzone->isPeerReview() ? 0 : 50;
                $this->manager->updateDropProgression($dropzone, $drop, $progression);
            }

            return new JsonResponse($documents);
        } catch (\Exception $e) {
            return new JsonResponse($e->getMessage(), 422);
        }
    }
public function addDocumentAction ( Drop $ drop , $ type , User $ user , Request $ request ) { $ dropzone = $ drop -> getDropzone ( ) ; $ this -> checkPermission ( 'OPEN' , $ dropzone -> getResourceNode ( ) , [ ] , true ) ; $ this -> checkDropEdition ( $ drop , $ user ) ; $ documents = [ ] ; try { if ( ! $ drop -> isFinished ( ) ) { switch ( $ type ) { case Document :: DOCUMENT_TYPE_FILE : $ files = $ request -> files -> all ( ) ; $ documents = $ this -> manager -> createFilesDocuments ( $ drop , $ user , $ files ) ; break ; case Document :: DOCUMENT_TYPE_TEXT : case Document :: DOCUMENT_TYPE_URL : case Document :: DOCUMENT_TYPE_RESOURCE : $ uuid = $ request -> request -> get ( 'dropData' , false ) ; $ document = $ this -> manager -> createDocument ( $ drop , $ user , $ type , $ uuid ) ; $ documents [ ] = $ this -> manager -> serializeDocument ( $ document ) ; break ; } $ progression = $ dropzone -> isPeerReview ( ) ? 0 : 50 ; $ this -> manager -> updateDropProgression ( $ dropzone , $ drop , $ progression ) ; } return new JsonResponse ( $ documents ) ; } catch ( \ Exception $ e ) { return new JsonResponse ( $ e -> getMessage ( ) , 422 ) ; } }
Adds a Document to a Drop.

@EXT\Route("/drop/{id}/type/{type}", name="claro_dropzone_documents_add")
@EXT\Method("POST")
@EXT\ParamConverter(
"drop",
class="ClarolineDropZoneBundle:Drop",
options={"mapping": {"id": "uuid"}}
)
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})

@param Drop    $drop
@param int     $type
@param User    $user
@param Request $request

@return JsonResponse
Adds a Document to a Drop .