From ec8bc93743a0040cf2d07310df832a2b86a1467d Mon Sep 17 00:00:00 2001 From: Thai Phan Date: Sun, 17 Feb 2019 13:39:32 +1100 Subject: [PATCH] Add theme favicons to S3 --- Model/Theme/Design/Backend/Favicon/Plugin.php | 53 +++++++++++++++++++ etc/di.xml | 3 ++ 2 files changed, 56 insertions(+) create mode 100644 Model/Theme/Design/Backend/Favicon/Plugin.php diff --git a/Model/Theme/Design/Backend/Favicon/Plugin.php b/Model/Theme/Design/Backend/Favicon/Plugin.php new file mode 100644 index 0000000..309d6ed --- /dev/null +++ b/Model/Theme/Design/Backend/Favicon/Plugin.php @@ -0,0 +1,53 @@ +helper = $helper; + $this->database = $database; + } + + /** + * @param Favicon $subject + * @param Favicon $result + * @return Favicon + */ + public function afterBeforeSave(Favicon $subject, Favicon $result) + { + if ($this->helper->checkS3Usage()) { + $imgFile = $subject::UPLOAD_DIR . '/' . $subject->getValue(); + $relativeImgFile = $this->database->getMediaRelativePath($imgFile); + $this->database->getStorageDatabaseModel()->saveFile($relativeImgFile); + } + + return $result; + } +} diff --git a/etc/di.xml b/etc/di.xml index 95866ed..767560e 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -63,4 +63,7 @@ + + +