ElggObject::__construct PHP Method

__construct() public method

Plugin developers should only use the constructor to create a new entity. To retrieve entities, use get_entity() and the elgg_get_entities* functions. If no arguments are passed, it creates a new entity. If a database result is passed as a \stdClass instance, it instantiates that entity.
public __construct ( stdClass $row = null )
$row stdClass Database row result. Default is null to create a new object.
    public function __construct(\stdClass $row = null)
    {
        $this->initializeAttributes();
        if ($row) {
            // Load the rest
            if (!$this->load($row)) {
                $msg = "Failed to load new " . get_class($this) . " for GUID: " . $row->guid;
                throw new \IOException($msg);
            }
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Construct hjFrom
  */
 function __construct($guid = null)
 {
     parent::__construct($guid);
     if (!$guid) {
         $this->setDefaults();
     }
 }
All Usage Examples Of ElggObject::__construct