/** * @param array $source * @param PropertyMappingConfigurationInterface $configuration * @return PersistentResource|FlowError * @throws \Exception */ protected function handleFileUploads(array $source, PropertyMappingConfigurationInterface $configuration = null) { if (!isset($source['error']) || $source['error'] === \UPLOAD_ERR_NO_FILE) { if (isset($source['originallySubmittedResource']) && isset($source['originallySubmittedResource']['__identity'])) { return $this->persistenceManager->getObjectByIdentifier($source['originallySubmittedResource']['__identity'], PersistentResource::class); } return null; } if ($source['error'] !== \UPLOAD_ERR_OK) { switch ($source['error']) { case \UPLOAD_ERR_INI_SIZE: case \UPLOAD_ERR_FORM_SIZE: case \UPLOAD_ERR_PARTIAL: return new FlowError(Files::getUploadErrorMessage($source['error']), 1264440823); default: $this->systemLogger->log(sprintf('A server error occurred while converting an uploaded resource: "%s"', Files::getUploadErrorMessage($source['error'])), LOG_ERR); return new FlowError('An error occurred while uploading. Please try again or contact the administrator if the problem remains', 1340193849); } } if (isset($this->convertedResources[$source['tmp_name']])) { return $this->convertedResources[$source['tmp_name']]; } try { $resource = $this->resourceManager->importUploadedResource($source, $this->getCollectionName($source, $configuration)); $this->convertedResources[$source['tmp_name']] = $resource; return $resource; } catch (\Exception $exception) { $this->systemLogger->log('Could not import an uploaded file', LOG_WARNING); $this->systemLogger->logException($exception); return new FlowError('During import of an uploaded file an error occurred. See log for more details.', 1264517906); } }