/** * Add a property related to this information object * * @param string $name Name of property * @param string $value Value of property * @param string $options array of optional parameters * @return QubitInformationObject this information object */ public function addProperty($name, $value, $options = array()) { // Don't re-add a property that exists already if (null != $this->id && QubitProperty::isExistent($this->id, $name, $value, $options)) { return; } $property = new QubitProperty(); $property->setName($name); $property->setValue($value, $options); if (isset($options['scope'])) { $property->setScope($options['scope']); } // Add property to related items, to save with QubitInfoObject::save(); $this->propertys[] = $property; return $this; }
/** * Add property after verifying that there isn't already one with an identical * object_id, name, and (optionally) scope. * * @param integer $objectId related object foreign key * @param string $name name of property * @param string $value value to set for property * @param array $options optional parameters * @return QubitProperty this property object */ public static function addUnique($objectId, $name, $value, $options = array()) { // Only add if an existing property does not exist if (!QubitProperty::isExistent($objectId, $name, $value, $options)) { $property = new QubitProperty(); $property->setObjectId($objectId); $property->setName($name); $property->setValue($value, $options); if (isset($options['scope'])) { $property->setScope($options['scope']); } $property->save(); return $property; } return null; }