From 28f4cbeac4d1df5298306593d03624b3f53984ac Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 30 May 2019 19:13:11 +0200 Subject: [PATCH] Implemented virtual path for media module. First test implementation done in the Helper module. The upload component is using a bad workaround where the virtual path is defined in the uri as ?virutalPath= because we are not uploading media files AND form data at the same time. Therefore the virtualPath can currently only be passed in the get/uri data. --- Admin/Install/Media.install.json | 7 ++++ Admin/Install/Media.php | 43 ++++++++++++++++++++ Controller/ApiController.php | 1 + Theme/Backend/helper-template-create.tpl.php | 2 +- info.json | 3 +- 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 Admin/Install/Media.install.json create mode 100644 Admin/Install/Media.php diff --git a/Admin/Install/Media.install.json b/Admin/Install/Media.install.json new file mode 100644 index 0000000..31b51f9 --- /dev/null +++ b/Admin/Install/Media.install.json @@ -0,0 +1,7 @@ +[ + { + "name": "Helper", + "virtualPath": "/Modules", + "user": 1 + } +] \ No newline at end of file diff --git a/Admin/Install/Media.php b/Admin/Install/Media.php new file mode 100644 index 0000000..612a8ad --- /dev/null +++ b/Admin/Install/Media.php @@ -0,0 +1,43 @@ + __DIR__ . '/Media.install.json']); + } +} diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 5fcc73c..38d79ef 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -268,6 +268,7 @@ final class ApiController extends Controller $mediaCollection->setDescriptionRaw((string) ($request->getData('description') ?? '')); $mediaCollection->setCreatedBy($request->getHeader()->getAccount()); $mediaCollection->setSources($files); + $mediaCollection->setVirtualPath('/Modules/Helper'); CollectionMapper::create($mediaCollection); diff --git a/Theme/Backend/helper-template-create.tpl.php b/Theme/Backend/helper-template-create.tpl.php index 3844659..49f3e2f 100644 --- a/Theme/Backend/helper-template-create.tpl.php +++ b/Theme/Backend/helper-template-create.tpl.php @@ -48,6 +48,6 @@ echo $this->getData('nav')->render(); ?>
- getData('media-upload')->render('helper-template-create'); ?> + getData('media-upload')->render('helper-template-create', '/Modules/Helper'); ?>
\ No newline at end of file diff --git a/info.json b/info.json index 0a7fca9..f067e56 100644 --- a/info.json +++ b/info.json @@ -22,7 +22,8 @@ "Tools": "1.0.0" }, "providing": { - "Navigation": "*" + "Navigation": "*", + "Media": "*" }, "load": [ {