Flex: Fixed uploading images when creating a new object

This commit is contained in:
Matias Griese
2018-12-13 13:49:04 +02:00
parent d6115007ab
commit 56c7b8ca5f
2 changed files with 10 additions and 9 deletions

View File

@@ -458,6 +458,13 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
$this->triggerEvent('onBeforeSave');
$result = $this->getFlexDirectory()->getStorage()->replaceRows([$this->getStorageKey() => $this->prepareStorage()]);
$value = reset($result);
$storageKey = key($result);
if ($value && $storageKey) {
$this->setStorageKey($storageKey);
}
if (method_exists($this, 'saveUpdatedMedia')) {
$this->saveUpdatedMedia();
}
@@ -475,12 +482,6 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
// Caching failed, but we can ignore that for now.
}
$value = reset($result);
$storageKey = key($result);
if ($value && $storageKey) {
$this->setStorageKey($storageKey);
}
$this->triggerEvent('onAfterSave');
return $this;

View File

@@ -27,7 +27,7 @@ trait FlexMediaTrait
{
use MediaTrait;
protected $uploads;
protected $_uploads;
public function __debugInfo()
{
@@ -210,7 +210,7 @@ trait FlexMediaTrait
}
}
$this->uploads = $list;
$this->_uploads = $list;
}
/**
@@ -218,7 +218,7 @@ trait FlexMediaTrait
*/
protected function getUpdatedMedia(): array
{
return $this->uploads ?? [];
return $this->_uploads ?? [];
}
protected function saveUpdatedMedia(): void