/** * Make a new attribute this object with the given key. The $nosave flag should only be set when * populating a parent node from storage. * @param scalar $key. the key * @param boolean $save Set to true to not save the parent and attribute * @returns mixed. false on failure, the attribute created on succes */ protected function newAttribute($key, $save, $prefix) { if (!self::checkKey($key)) { self::raiseError("Invalid path component {$key}"); return false; } $attr = new I2CE_MagicDataNode('=' . $prefix . ':' . $key, $this, false); $attr->populate(); $attr->type = self::TYPE_STRING_VALUE; //just to be safe $this->attributes[$prefix][$key] = $attr; if ($save) { if (!$attr->save()) { return false; } if (!$this->save()) { return false; } } return $attr; }