mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
FlexObject: When creating object and key isn't set, use storage key instead
This commit is contained in:
parent
4b1a129f38
commit
85af461eb4
|
|
@ -481,6 +481,9 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
$storageKey = key($result);
|
||||
if ($value && $storageKey) {
|
||||
$this->setStorageKey($storageKey);
|
||||
if (!$this->hasKey()) {
|
||||
$this->setKey($storageKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (method_exists($this, 'saveUpdatedMedia')) {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,14 @@ trait ObjectTrait
|
|||
return $this->_key ?: $this->getType() . '@@' . spl_object_hash($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasKey()
|
||||
{
|
||||
return !empty($this->_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $property Object property name.
|
||||
* @return bool True if property has been defined (can be null).
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user