Source code for file /joomla/base/object.php
Documentation is available at object.php
* @version $Id: object.php 9764 2007-12-30 07:48:11Z ircmaxell $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
* Object class, allowing __construct in PHP4.
* @author Johan Janssens <johan.janssens@joomla.org>
* @package Joomla.Framework
* @var array of error messages or JExceptions objects
* A hack to support __construct() on PHP 4
* Hint: descendant classes have no PHP4 class_name() constructors,
* so this constructor gets called first and calls the top-layer __construct()
* which (if present) should call parent::__construct()
* Class constructor, overridden in descendant classes.
* Returns a property of the object or the default value if the property is not set.
* @param string $property The name of the property
* @param mixed $default The default value
* @return mixed The value of the property
function get($property, $default=
null)
if(isset
($this->$property)) {
* Returns an associative array of object properties
* @param boolean $public If true, returns only the public properties
foreach ($vars as $key =>
$value)
if ('_' ==
substr($key, 0, 1)) {
* Get the most recent error message
* @param integer $i Option error index
* @param boolean $toString Indicates if JError objects should return their error message
* @return string Error message
function getError($i =
null, $toString =
true )
// Default, return the last message
// If $i has been specified but does not exist, return false
// Check if only the string is requested
return $error->toString();
* Return all errors, if any
* @return array Array of error messages or JErrors
* Modifies a property of the object, creating it if it does not already exist.
* @param string $property The name of the property
* @param mixed $value The value of the property to set
* @return mixed Previous value of the property
function set( $property, $value =
null )
$previous = isset
($this->$property) ?
$this->$property :
null;
$this->$property =
$value;
* Set the object properties based on a named array/hash
* @param $array mixed Either and associative array or another object
$properties = (array)
$properties; //cast to an array
foreach ($properties as $k =>
$v) {
* @param string $error Error message
* Object-to-string conversion.
* Each class can override it as necessary.
* @return string This name of this class
* Legacy Method, use {@link JObject::getProperties()} instead