Skip to content

Commit

Permalink
BackwardsCompatibilityBreak - fORMColumn::configureMoneyColumn() was …
Browse files Browse the repository at this point in the history
…moved to fORMMoney::configureMoneyColumn(). fORMMoney::configureMoneyColumn() now accepts a column to be used for storing the currency. Added fActiveRecord::assign() for standardizing $values -> $old_values storage, updated fActiveRecord, fORMFile and fORMColumn to use it.
  • Loading branch information
wbond committed Apr 12, 2012
1 parent ffc3d68 commit 37eae73
Show file tree
Hide file tree
Showing 4 changed files with 659 additions and 313 deletions.
31 changes: 24 additions & 7 deletions classes/database/object_relational_mapping/fActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@
*/
abstract class fActiveRecord
{
/**
* Sets a value, preserving the old value to future reference
*
* @internal
*
* @param array &$values The current values
* @param array &$old_values The old values
* @param string $column The column to set
* @param mixed $value The value to set
* @return void
*/
static public function assign(&$values, &$old_values, $column, $value)
{
if (!isset($old_values[$column])) {
$old_values[$column] = array();
}

$old_values[$column][] = $values[$column];
$values[$column] = $value;
}


/**
* The old values for this record
*
Expand Down Expand Up @@ -856,7 +878,7 @@ protected function loadFromIdentityMap($source)
$pk_columns = fORMSchema::getInstance()->getKeys(fORM::tablize($this), 'primary');

// If we don't have a value for each primary key, we can't load
if (is_array($row) && !array_diff($pk_columns, array_keys($row))) {
if (is_array($row) && array_diff($pk_columns, array_keys($row))) {
return FALSE;
}

Expand Down Expand Up @@ -1319,12 +1341,7 @@ protected function set($column, $value)

$value = fORM::objectify($this, $column, $value);

if (!isset($this->old_values[$column])) {
$this->old_values[$column] = array();
}

$this->old_values[$column][] = $this->values[$column];
$this->values[$column] = $value;
self::assign($this->values, $this->old_values, $column, $value);
}


Expand Down
Loading

0 comments on commit 37eae73

Please sign in to comment.