コード例 #1
0
ファイル: abstract.php プロジェクト: nooku/nooku-framework
 /**
  * Set a property
  *
  * If the value is the same as the current value and the entity is loaded from the data store the value will not be
  * set. If the entity is new the value will be (re)set and marked as modified.
  *
  * Method provides support for computed properties by calling an setProperty[CamelizedName] if it exists. The setter
  * should return the computed value to set.
  *
  * @param   string  $name       The property name.
  * @param   mixed   $value      The property value.
  * @param   boolean $modified   If TRUE, update the modified information for the property
  *
  * @return  $this
  */
 public function setProperty($name, $value, $modified = true)
 {
     if (!array_key_exists($name, $this->_data) || $this->_data[$name] != $value) {
         $computed = $this->getComputedProperties();
         if (!in_array($name, $computed)) {
             //Force computed properties to re-calculate
             foreach ($computed as $property) {
                 parent::offsetUnset($property);
             }
             //Call the setter if it exists
             $setter = 'setProperty' . StringInflector::camelize($name);
             $methods = $this->getMethods();
             if (isset($methods[$setter])) {
                 $value = $this->{$setter}($value);
             }
             //Set the property value
             parent::offsetSet($name, $value);
             //Mark the property as modified
             if ($modified || $this->isNew()) {
                 $this->__modified_properties[$name] = $name;
                 $this->setStatus(Database::STATUS_MODIFIED);
             }
         }
     }
     return $this;
 }
コード例 #2
0
ファイル: abstract.php プロジェクト: janssit/nickys.janss.be
 /**
  * Set row field value
  *
  * If the value is the same as the current value and the row is loaded from the database the value will not be reset.
  * If the row is new the value will be (re)set and marked as modified
  *
  * @param   string  $column The column name.
  * @param   mixed   $value  The column value.
  * @return  void
  */
 public function offsetSet($column, $value)
 {
     if ($this->isNew() || !array_key_exists($column, $this->_data) || $this->_data[$column] != $value) {
         parent::offsetSet($column, $value);
         $this->_modified[$column] = $column;
     }
 }