class CMSObject

Joomla Platform Object Class

This class allows for simple but smart objects with get and set methods and an internal error handler.

Methods

__construct( mixed $properties = null)

Class constructor, overridden in descendant classes.

string
__toString()

Magic method to convert the object to a string gracefully.

mixed
def( string $property, mixed $default = null)

Sets a default value if not already assigned

mixed
get( string $property, mixed $default = null)

Returns a property of the object or the default value if the property is not set.

array
getProperties( boolean $public = true)

Returns an associative array of object properties.

string
getError( integer $i = null, boolean $toString = true)

Get the most recent error message.

array
getErrors()

Return all errors, if any.

mixed
set( string $property, mixed $value = null)

Modifies a property of the object, creating it if it does not already exist.

boolean
setProperties( mixed $properties)

Set the object properties based on a named array/hash.

void
setError( string $error)

Add an error message.

Details

__construct( mixed $properties = null)

Class constructor, overridden in descendant classes.

Parameters

mixed $properties Either and associative array or another object to set the initial properties of the object.

string __toString()

Magic method to convert the object to a string gracefully.

Return Value

string The classname.

mixed def( string $property, mixed $default = null)

Sets a default value if not already assigned

Parameters

string $property The name of the property.
mixed $default The default value.

Return Value

mixed

mixed get( string $property, mixed $default = null)

Returns a property of the object or the default value if the property is not set.

Parameters

string $property The name of the property.
mixed $default The default value.

Return Value

mixed The value of the property.

See also

CMSObject::getProperties()

array getProperties( boolean $public = true)

Returns an associative array of object properties.

Parameters

boolean $public If true, returns only the public properties.

Return Value

array

See also

CMSObject::get()

string getError( integer $i = null, boolean $toString = true)

Get the most recent error message.

Parameters

integer $i Option error index.
boolean $toString Indicates if JError objects should return their error message.

Return Value

string Error message

See also

JError

array getErrors()

Return all errors, if any.

Return Value

array Array of error messages or JErrors.

See also

JError

mixed set( string $property, mixed $value = null)

Modifies a property of the object, creating it if it does not already exist.

Parameters

string $property The name of the property.
mixed $value The value of the property to set.

Return Value

mixed Previous value of the property.

boolean setProperties( mixed $properties)

Set the object properties based on a named array/hash.

Parameters

mixed $properties Either an associative array or another object.

Return Value

boolean

See also

CMSObject::set()

void setError( string $error)

Add an error message.

Parameters

string $error Error message.

Return Value

void

See also

JError