mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Added $object->getOriginal() to get flex objects data before it was modified with update()
This commit is contained in:
parent
21db2e7d4a
commit
1350cf5675
|
|
@ -6,6 +6,7 @@
|
|||
* Added `route` and `request` to `onPageNotFound` event
|
||||
* Added file upload/remove support for `Flex Forms`
|
||||
* Added support for `flex-required@: not exists` and `flex-required@: '!exists'` in blueprints
|
||||
* Added `$object->getOriginal()` to get flex objects data before it was modified with `update()`
|
||||
* Throwing exceptions from Twig templates fires `onDisplayErrorPage.[code]` event allowing better error pages
|
||||
3. [](#bugfix)
|
||||
* Fixed escaping in PageIndex::getLevelListing()
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
/** @var array */
|
||||
private $_meta;
|
||||
/** @var array */
|
||||
protected $_original;
|
||||
/** @var array */
|
||||
protected $_changes;
|
||||
/** @var string */
|
||||
protected $storage_key;
|
||||
|
|
@ -441,6 +443,16 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get original data before update
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOriginal(): array
|
||||
{
|
||||
return $this->_original ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any changes based on data sent to update
|
||||
*
|
||||
|
|
@ -654,7 +666,8 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
}
|
||||
|
||||
// Store the changes
|
||||
$this->_changes = Utils::arrayDiffMultidimensional($this->getElements(), $elements);
|
||||
$this->_original = $this->getElements();
|
||||
$this->_changes = Utils::arrayDiffMultidimensional($this->_original, $elements);
|
||||
}
|
||||
|
||||
if ($files && method_exists($this, 'setUpdatedMedia')) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user