fORMMoneystatic classv1.0.0b6

Provides money functionality for fActiveRecord classes

Changes:
1.0.0b6Fixed duplicate validation messages and fProgrammerException object being thrown when NULL is set 3/3/10
1.0.0b5Updated code for the new fORMDatabase and fORMSchema APIs 10/28/09
1.0.0b4Updated to use new fORM::registerInspectCallback() method 7/13/09
1.0.0b3Updated code to use new fValidationException::formatField() method 6/4/09
1.0.0b2Fixed bugs with objectifying money columns 11/24/08
1.0.0bThe initial implementation 9/5/08

Static Methods

::configureMoneyColumn() public

Sets a column to be formatted as an fMoney object

Signature

void configureMoneyColumn( mixed $class, string $column, string $currency_column=NULL )

Parameters

mixed $class The class name or instance of the class to set the column format
string $column The column to format as an fMoney object
string $currency_column If specified, this column will store the currency of the fMoney object

::encodeMoneyColumn() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Encodes a money column by calling fMoney::__toString()

Signatures

string encodeMoneyColumn( fActiveRecord $object, string $method_name, array $parameters )

string encodeMoneyColumn( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record
string $method_name The method that was called
array $parameters The parameters passed to the method

Returns

The encoded monetary value

::inspect() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Adds metadata about features added by this class

Signatures

void inspect( string $class, string $column )

void inspect( array $metadata )

Parameters

string $class The class being inspected
string $column The column being inspected
array &$metadata The array of metadata about a column

::makeMoneyObjects() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Makes fMoney objects for all money columns in the object that also have a currency column

Signatures

void makeMoneyObjects( fActiveRecord $object )

void makeMoneyObjects( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record

::objectifyMoney() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Turns a monetary value into an fMoney object

Signature

mixed objectifyMoney( string $class, string $column, mixed $value )

Parameters

string $class The class this value is for
string $column The column the value is in
mixed $value The value

Returns

The fMoney object or raw value

::objectifyMoneyWithCurrency() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Turns a monetary value into an fMoney object with a currency specified by another column

Signatures

void objectifyMoneyWithCurrency( string $value_column, string $currency_column )

void objectifyMoneyWithCurrency( array $values, array $old_values )

Parameters

array &$values The current values
array &$old_values The old values
string $value_column The column holding the value
string $currency_column The column holding the currency code

::prepareMoneyColumn() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Prepares a money column by calling fMoney::format()

Signatures

string prepareMoneyColumn( fActiveRecord $object, string $method_name, array $parameters )

string prepareMoneyColumn( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record
string $method_name The method that was called
array $parameters The parameters passed to the method

Returns

The formatted monetary value

::reflect() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Adjusts the fActiveRecord::reflect() signatures of columns that have been configured in this class

Signatures

void reflect( string $class, boolean $include_doc_comments )

void reflect( array $signatures )

Parameters

string $class The class to reflect
array &$signatures The associative array of {method name} => {signature}
boolean $include_doc_comments If doc comments should be included with the signature

::reset() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Resets the configuration of the class

Signature

void reset( )

::setCurrencyColumn() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the currency column and then tries to objectify the related money column

Signatures

void setCurrencyColumn( fActiveRecord $object, string $method_name, array $parameters )

void setCurrencyColumn( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record
string $method_name The method that was called
array $parameters The parameters passed to the method

::setMoneyColumn() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Sets the money column and then tries to objectify it with an related currency column

Signatures

void setMoneyColumn( fActiveRecord $object, string $method_name, array $parameters )

void setMoneyColumn( array $values, array $old_values, array $related_records, array $cache )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record
string $method_name The method that was called
array $parameters The parameters passed to the method

::validateMoneyColumns() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Validates all money columns

Signatures

void validateMoneyColumns( fActiveRecord $object )

void validateMoneyColumns( array $values, array $old_values, array $related_records, array $cache, array $validation_messages )

Parameters

fActiveRecord $object The fActiveRecord instance
array &$values The current values
array &$old_values The old values
array &$related_records Any records related to this record
array &$cache The cache array for the record
array &$validation_messages An array of ordered validation messages