/** * Adds the storage exceeded error in a form. * * @param Form $form * @param int $filesize */ public function addStorageExceededFormError(Form $form, $fileSize, Workspace $workspace) { $maxSize = $this->ut->getRealFileSize($workspace->getMaxStorageSize()); $usedSize = $this->ut->getRealFileSize($this->container->get('claroline.manager.workspace_manager')->getUsedStorage($workspace)); $storageLeft = $maxSize - $usedSize; $fileSize = $this->ut->formatFileSize($this->ut->getRealFileSize($fileSize)); $storageLeft = $this->ut->formatFileSize($storageLeft); $translator = $this->container->get('translator'); $msg = $translator->trans('storage_limit_exceeded', ['%storageLeft%' => $storageLeft, '%fileSize%' => $fileSize], 'platform'); $form->addError(new FormError($msg)); }
/** * Adds the storage exceeded error in a form. * * @param Form $form * @param integer $filesize */ public function addStorageExceededFormError(Form $form, $fileSize, Workspace $workspace) { $filesize = $this->ut->getRealFileSize($fileSize); //we want how many bites and well... $maxSize = $this->ut->getRealFileSize($workspace->getMaxStorageSize()); //throw new \Exception($maxSize); $usedSize = $this->ut->getRealFileSize($this->container->get('claroline.manager.workspace_manager')->getUsedStorage($workspace)); $storageLeft = $maxSize - $usedSize; $fileSize = $this->ut->formatFileSize($fileSize); $storageLeft = $this->ut->formatFileSize($storageLeft); $translator = $this->container->get('translator'); $msg = $translator->trans('storage_limit_exceeded', array('%storageLeft%' => $storageLeft, '%fileSize%' => $fileSize), 'platform'); $form->addError(new FormError($msg)); }
public function exportWorkspace(Workspace $workspace) { return ['id' => $workspace->getId(), 'guid' => $workspace->getGuid(), 'name' => $workspace->getName(), 'description' => $workspace->getDescription(), 'code' => $workspace->getCode(), 'maxStorageSize' => $workspace->getMaxStorageSize(), 'maxUploadResources' => $workspace->getMaxUploadResources(), 'maxUsers' => $workspace->getMaxUsers(), 'displayable' => $workspace->isDisplayable(), 'creatorId' => $workspace->getCreator()->getId(), 'selfRegistration' => $workspace->getSelfRegistration(), 'registrationValidation' => $workspace->getRegistrationValidation(), 'selfUnregistration' => $workspace->getSelfUnregistration(), 'creationDate' => $workspace->getCreationDate(), 'isPersonal' => $workspace->isPersonal(), 'startDate' => $workspace->getStartDate(), 'endDate' => $workspace->getEndDate(), 'isAccessDate' => $workspace->getIsAccessDate(), 'type' => $workspace->getWorkspaceType()]; }