From c2fc48bc5ca56d662e9cde52a56137f80b120b0d Mon Sep 17 00:00:00 2001 From: Guite Date: Mon, 7 Nov 2016 17:18:22 +0100 Subject: [PATCH] minor additions for Symfony's kind of upload handling, refs #541 --- .../zclassic/controller/FormHandler.xtend | 14 +++++++++++++- .../generator/extensions/ModelExtensions.xtend | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/controller/FormHandler.xtend b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/controller/FormHandler.xtend index a58bd2ae5..b59d35438 100644 --- a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/controller/FormHandler.xtend +++ b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/controller/FormHandler.xtend @@ -1285,8 +1285,11 @@ class FormHandler { «ENDIF» «locking.imports(it)» «IF !app.isLegacy» - use Symfony\Component\Security\Core\Exception\AccessDeniedException; + «IF hasUploadFieldsEntity» + use Symfony\Component\HttpFoundation\File\File; + «ENDIF» use Symfony\Component\HttpFoundation\RedirectResponse; + use Symfony\Component\Security\Core\Exception\AccessDeniedException; use ModUtil; use RuntimeException; use System; @@ -1360,6 +1363,15 @@ class FormHandler { «ENDIF» } } + «IF !app.isLegacy && hasUploadFieldsEntity» + + // file field type expects File instances instead of file names + $controllerHelper = $this->container->get('«app.appService».controller_helper'); + foreach ($this->uploadFields as $uploadFieldName => $isMandatory) { + «FOR uploadField : getUploadFieldsEntity» + $entity[$uploadFieldName] = new File($controllerHelper->getFileBaseFolder($this->objectType, $uploadFieldName) . $entity[$uploadFieldName]); + «ENDFOR» + «ENDIF» return $entity; } diff --git a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/extensions/ModelExtensions.xtend b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/extensions/ModelExtensions.xtend index 0267d9ed7..83d8a903b 100644 --- a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/extensions/ModelExtensions.xtend +++ b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/extensions/ModelExtensions.xtend @@ -725,7 +725,7 @@ class ModelExtensions { TextField: 'text' EmailField: 'string' UrlField: 'string' - UploadField: if (entity.application.targets('1.3.x')) 'string' else 'File' + UploadField: 'string' ListField: 'string' ArrayField: 'array' ObjectField: 'object'