Since: 1.7.0

class CMSObject extends stdClass

deprecated 4.3 will be removed in 6.0 Use \stdClass or \Joomla\Registry\Registry instead. Example: new \Joomla\Registry\Registry();

Joomla Platform Object Class

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

Traits

Trait which contains the legacy methods that formerly were inherited from \Joomla\CMS\Object\CMSObject to set and get errors in a class.

Trait which contains the legacy methods that formerly were inherited from \Joomla\CMS\Object\CMSObject to set and get properties of the current class.

Properties

protected array deprecated Since: 1.7.0
$_errors

An array of error messages or Exception objects.

from  LegacyErrorHandlingTrait

Methods

string
getError(int $i = null, bool $toString = true) deprecated

Get the most recent error message.

array
getErrors() deprecated

Return all errors, if any.

void
setError(string $error) deprecated

Add an error message.

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

Sets a default value if not already assigned

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

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

array
getProperties(bool $public = true) deprecated

Returns an associative array of object properties.

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

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

bool
setProperties(mixed $properties) deprecated

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

__construct(mixed $properties = null)

Class constructor, overridden in descendant classes.

string
__toString() deprecated

Magic method to convert the object to a string gracefully.

Details

string getError(int $i = null, bool $toString = true) deprecated

Since: 1.7.0

deprecated 3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getError

Get the most recent error message.

Parameters

int $i

Option error index.

bool $toString

Indicates if Exception objects should return their error message.

Return Value

string

Error message

array getErrors() deprecated

Since: 1.7.0

deprecated 3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getErrors

Return all errors, if any.

Return Value

array

Array of error messages.

void setError(string $error) deprecated

Since: 1.7.0

deprecated 3.1.4 will be removed in 6.0 Will be removed without replacement Throw an Exception instead of using setError

Add an error message.

Parameters

string $error

Error message.

Return Value

void

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

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Defining dynamic properties should not be used anymore

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

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Create a proper getter function for the property

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

\Joomla\CMS\Object\CMSObject::getProperties()

array getProperties(bool $public = true) deprecated

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Create a proper getter function for the property

Returns an associative array of object properties.

Parameters

bool $public

If true, returns only the public properties.

Return Value

array

See also

\Joomla\CMS\Object\CMSObject::get()

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

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Create a proper setter function for the property

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.

bool setProperties(mixed $properties) deprecated

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Create a proper setter function for the property

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

Parameters

mixed $properties

Either an associative array or another object.

Return Value

bool

See also

\Joomla\CMS\Object\CMSObject::set()

__construct(mixed $properties = null)

Since: 1.7.0

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

Since: 1.7.0

deprecated 4.3 will be removed in 6.0 Classes should provide their own __toString() implementation.

Magic method to convert the object to a string gracefully.

Return Value

string

The classname.