FlexObject: When creating object and key isn't set, use storage key instead

This commit is contained in:
Matias Griese 2019-03-01 15:13:21 +02:00
parent 4b1a129f38
commit 85af461eb4
2 changed files with 11 additions and 0 deletions

View File

@ -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')) {

View File

@ -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).