ElggObject::load PHP Method

load() protected method

Loads the full \ElggObject when given a guid.
protected load ( mixed $guid ) : boolean
$guid mixed GUID of an \ElggObject or the \stdClass object from entities table
return boolean
    protected function load($guid)
    {
        $attr_loader = new \Elgg\AttributeLoader(get_class(), 'object', $this->attributes);
        $attr_loader->requires_access_control = !$this instanceof \ElggPlugin;
        $attr_loader->secondary_loader = 'get_object_entity_as_row';
        $attrs = $attr_loader->getRequiredAttributes($guid);
        if (!$attrs) {
            return false;
        }
        $this->attributes = $attrs;
        $this->loadAdditionalSelectValues($attr_loader->getAdditionalSelectValues());
        _elgg_services()->entityCache->set($this);
        return true;
    }

Usage Example

 protected function load($guid)
 {
     if (!parent::load($guid)) {
         return false;
     }
     $metadata_options = array('guid' => $guid, 'limit' => false);
     if ($metadata = elgg_get_metadata($metadata_options)) {
         if (!is_array($this->meta_cache)) {
             $this->meta_cache = array();
         }
         foreach ($metadata as $md) {
             $this->meta_cache[$md->name] = $md->value;
         }
     }
     return true;
 }
All Usage Examples Of ElggObject::load