From 89a0e960e2c9e6c6ec201f0b7b9de14c4a71da33 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 12 Dec 2018 16:14:55 +0200 Subject: [PATCH] Improve file upload logic on flex objects --- system/src/Grav/Framework/Flex/FlexForm.php | 7 +------ system/src/Grav/Framework/Flex/FlexObject.php | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/system/src/Grav/Framework/Flex/FlexForm.php b/system/src/Grav/Framework/Flex/FlexForm.php index 91ff7c755..85504b1a6 100644 --- a/system/src/Grav/Framework/Flex/FlexForm.php +++ b/system/src/Grav/Framework/Flex/FlexForm.php @@ -496,12 +496,7 @@ class FlexForm implements FlexFormInterface { /** @var FlexObject $object */ $object = clone $this->getObject(); - $object->update($data); - - if ($files && method_exists($object, 'upload')) { - $object->upload($files); - } - + $object->update($data, $files); $object->save(); $this->setObject($object); diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index 1194248c2..57f6f57aa 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -118,10 +118,6 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface // Validate and filter the incoming data. $blueprint = $this->getFlexDirectory()->getBlueprint(); - if ($files && method_exists($this, 'updateMediaFiles')) { - $this->updateMediaFiles($files); - } - if ($data) { // Filter updated data. $this->filterElements($data); @@ -138,6 +134,10 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface $this->setElements($data); } + if ($files && method_exists($this, 'updateMediaFiles')) { + $this->updateMediaFiles($files); + } + return $this; }