Flourish PHP Unframework

fORMColumn

static class, v1.0.0b15

Provides special column functionality for fActiveRecord classes

Changes:
1.0.0b15Fixed a bug with empty string email values passing through required validation 7/29/11
1.0.0b14Updated code to work with the new fORM API 8/6/10
1.0.0b13Fixed reflect() to include some missing parameters 6/8/10
1.0.0b12Changed validation messages array to use column name keys 5/26/10
1.0.0b11Fixed a bug with prepareLinkColumn() returning http:// for empty link columns and not adding http:// to links that contained a /, but did not start with it 3/16/10
1.0.0b10Fixed reflect() to specify the value returned from set and generate methods, changed generate() methods to return the newly generated string 3/15/10
1.0.0b9Changed email columns to be automatically trimmed if they are a value email address surrounded by whitespace 3/14/10
1.0.0b8Made the validation on link columns a bit more strict 3/9/10
1.0.0b7Updated code for the new fORMDatabase and fORMSchema APIs 10/28/09
1.0.0b6Changed SQL statements to use value placeholders, identifier escaping and schema support 10/22/09
1.0.0b5Updated to use new fORM::registerInspectCallback() method 7/13/09
1.0.0b4Updated code for new fORM API 6/15/09
1.0.0b3Updated code to use new fValidationException::formatField() method 6/4/09
1.0.0b2Fixed a bug with objectifying number columns 11/24/08
1.0.0bThe initial implementation 5/27/08

Static Methods

::configureEmailColumn() public

Sets a column to be formatted as an email address

Signature

void configureEmailColumn( mixed $class, string $column )

Parameters

mixed $class The class name or instance of the class to set the column format
string $column The column to format as an email address

::configureLinkColumn() public

Sets a column to be formatted as a link

Signature

void configureLinkColumn( mixed $class, string $column )

Parameters

mixed $class The class name or instance of the class to set the column format
string $column The column to format as a link

::configureNumberColumn() public

Sets a column to be returned as an fNumber object from calls to get{ColumnName}()

Signature

void configureNumberColumn( mixed $class, string $column )

Parameters

mixed $class The class name or instance of the class to set the column format
string $column The column to return as an fNumber object

::configureRandomColumn() public

Sets a column to be a random string column - a random string will be generated when the record is saved

Signature

void configureRandomColumn( mixed $class, string $column, string $type, integer $length )

Parameters

mixed $class The class name or instance of the class
string $column The column to set as a random column
string $type The type of random string, must be one of: 'alphanumeric', 'alpha', 'numeric', 'hexadecimal'
integer $length The length of the random string

::encodeNumberColumn() 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 number column by calling fNumber::__toString()

Signature

string encodeNumberColumn( fActiveRecord $object, array &$values, array &$old_values, array &$related_records, array &$cache, string $method_name, array $parameters )

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 number

::generate() 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

Generates a new random value for the column

Signature

string generate( fActiveRecord $object, array &$values, array &$old_values, array &$related_records, array &$cache, string $method_name, array $parameters )

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 newly generated random 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

Signature

void inspect( string $class, string $column, array &$metadata )

Parameters

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

::objectifyNumber() 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 numeric value into an fNumber object

Signature

mixed objectifyNumber( 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 fNumber object or raw value

::prepareLinkColumn() 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 link column so that the link will work properly in an a tag

Signature

string prepareLinkColumn( fActiveRecord $object, array &$values, array &$old_values, array &$related_records, array &$cache, string $method_name, array $parameters )

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 link

::prepareNumberColumn() 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 number column by calling fNumber::format()

Signature

string prepareNumberColumn( fActiveRecord $object, array &$values, array &$old_values, array &$related_records, array &$cache, string $method_name, array $parameters )

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 link

::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

Signature

void reflect( string $class, array &$signatures, boolean $include_doc_comments )

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( )

::setEmailColumn() 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 value for an email column, trimming the value if it is a valid email

Signature

fActiveRecord setEmailColumn( fActiveRecord $object, array &$values, array &$old_values, array &$related_records, array &$cache, string $method_name, array $parameters )

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 record object, to allow for method chaining

::setRandomStrings() 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 appropriate column values to a random string if the object is new

Signature

string setRandomStrings( fActiveRecord $object, 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

Returns

The formatted link

::validateEmailColumns() 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 email columns

Signature

void validateEmailColumns( fActiveRecord $object, 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

::validateLinkColumns() 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 link columns

Signature

void validateLinkColumns( fActiveRecord $object, 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