SnapObject Class Reference
[Core]

Base class for all non-static Snap objects. More...

Inheritance diagram for SnapObject:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 getAttributes ()
 Retrieves the names of all the object's attributes.
 getFields ()
 Retrieves the names of all the object's fields.
 getId ()
 Retrieves object ID.
 getReason ()
 Retrieves user-targetted error message.
 getType ()
 Retrieves the object type.
 getValues ()
 Retrieves values for all fields in the object.
 isLoaded ($field)
 Determines whether a field has been loaded.
 isValid ()
 Returns whether object is valid.


Detailed Description

Base class for all non-static Snap objects.

This class essentially provides utility methods and features to make it easier to implement the derived classes. Most notably, it supports fields and attributes, as well as autoloader methods, so that objects can easily have lazy loading of database attributes and other fields, for performance reasons.


Member Function Documentation

SnapObject::getAttributes (  ) 

Retrieves the names of all the object's attributes.

Note that these attributes are also fields. For objects which do not have a direct database representation, there should be no attributes (e.g., SnapPermission).

Returns:
[array]: flat array of attribute names, or false if object is invalid

SnapObject::getFields (  ) 

Retrieves the names of all the object's fields.

Returns:
[array]: flat array of field names, or false if object is invalid

SnapObject::getId (  ) 

Retrieves object ID.

All Snap objects should have an ID of some sort. For those objects which correspond to database entities, the ID will be the primary key of the row that the object represents. For those objects which do not correspond to database entities (such as SnapPermission), the ID still uniquely represents the object in some useful way.

Returns:
[mixed]: ID of object or false if object is invalid

SnapObject::getReason (  ) 

Retrieves user-targetted error message.

This is used primarily by the _canXxx() methods to indicate why an operation could not be performed. To display an error message to the user, call this method.

Returns:
[string]: error message

SnapObject::getType (  ) 

Retrieves the object type.

Returns:
[string]: object type

SnapObject::getValues (  ) 

Retrieves values for all fields in the object.

Note that this method will NOT autoload unloaded fields. If you want those values returned here, you must trigger an autoload by, e.g., calling getXxx() where "Xxx" is the name of the field that needs to be autoloaded.

Returns:
[array]: associative array of field name => value pairs or false if object is invalid

SnapObject::isLoaded ( field  ) 

Determines whether a field has been loaded.

Parameters:
$field [string]: which field to check
Returns:
[boolean]: whether field has been auto-loaded yet, or false if field is invalid or object is invalid

SnapObject::isValid (  ) 

Returns whether object is valid.

See setValid() for more on what it means for an object to be valid

Returns:
[boolean]: whether object is valid


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:03:19 2010 for Common by  doxygen 1.5.6