private function handleFileCreation($form, CreateResourceEvent $event) { $workspace = $event->getParent()->getWorkspace(); $workspaceDir = $this->workspaceManager->getStorageDirectory($workspace); $isStorageLeft = $this->resourceManager->checkEnoughStorageSpaceLeft($workspace, $form->get('file')->getData()); if (!$isStorageLeft) { $this->resourceManager->addStorageExceededFormError($form, filesize($form->get('file')->getData()), $workspace); } else { //check if there is enough space liedt //$file is the entity //$tmpFile is the other file $file = $form->getData(); $tmpFile = $form->get('file')->getData(); //the tmpFile may require some encoding. if ($encoding = $event->getEncoding() !== 'none') { $tmpFile = $this->encodeFile($tmpFile, $event->getEncoding()); } $published = $form->get('published')->getData(); $event->setPublished($published); $fileName = $tmpFile->getClientOriginalName(); $ext = strtolower($tmpFile->getClientOriginalExtension()); $mimeType = $this->container->get('claroline.utilities.mime_type_guesser')->guess($ext); if (!is_dir($workspaceDir)) { mkdir($workspaceDir); } if (pathinfo($fileName, PATHINFO_EXTENSION) === 'zip' && $form->get('uncompress')->getData()) { $roots = $this->unzip($tmpFile, $event->getParent(), $published); $event->setResources($roots); //do not process the resources afterwards because nodes have been created with the unzip function. $event->setProcess(false); $event->stopPropagation(); } else { $file = $this->createFile($file, $tmpFile, $fileName, $mimeType, $workspace); $event->setResources(array($file)); $event->stopPropagation(); } } }