mirror of
https://github.com/getgrav/grav.git
synced 2026-03-03 02:51:29 +01:00
Flex: Fixed uploading images when creating a new object
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user