aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/entities.php32
1 files changed, 25 insertions, 7 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 2cadf199c..850da0008 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -31,7 +31,8 @@
* Subclasses should add to this in their constructors.
* Any field not appearing in this will be viewed as a
*/
- protected $attributes;
+ protected $attributes;
+ protected $temp_metadata;
/**
* Initialise the attributes array.
@@ -45,6 +46,7 @@
{
// Create attributes array if not already created
if (!is_array($this->attributes)) $this->attributes = array();
+ if (!is_array($this->temp_metadata)) $this->temp_metadata = array();
$this->attributes['guid'] = "";
$this->attributes['type'] = "";
@@ -74,10 +76,15 @@
return $this->attributes[$name];
}
- // No, so see if its in the meta data for this entity
- $meta = $this->getMetaData($name);
- if ($meta)
- return $meta;
+ // No, so see if its in the meta data for this entity
+ if (isset($this->guid)) {
+ $meta = $this->getMetaData($name);
+ if ($meta)
+ return $meta;
+ } else {
+ if (isset($this->temp_metadata[$name]))
+ return $this->temp_metadata[$name];
+ }
// Can't find it, so return null
return null;
@@ -108,8 +115,11 @@
$this->attributes[$name] = $value;
}
- else
- return $this->setMetaData($name, $value);
+ else if (isset($this->guid)) {
+ return $this->setMetaData($name, $value);
+ } else {
+ $this->temp_metadata[$name] = $value;
+ }
return true;
}
@@ -371,6 +381,14 @@
{
$this->attributes['guid'] = create_entity($this->attributes['type'], $this->attributes['subtype'], $this->attributes['owner_guid'], $this->attributes['access_id']); // Create a new entity (nb: using attribute array directly 'cos set function does something special!)
if (!$this->attributes['guid']) throw new IOException("Unable to save new object's base entity information!");
+
+ // Save any unsaved metadata
+ if (sizeof($this->temp_metadata) > 0) {
+ foreach($this->temp_metadata as $name => $value) {
+ $this->$name = $value;
+ unset($this->temp_metadata[$name]);
+ }
+ }
return $this->attributes['guid'];
}