Пример #1
0
 /**
  * Loads the full ElggSite when given a guid.
  *
  * @param int $guid Guid of ElggSite entity
  *
  * @return bool
  * @throws InvalidClassException
  */
 protected function load($guid)
 {
     // Test to see if we have the generic stuff
     if (!parent::load($guid)) {
         return false;
     }
     // Check the type
     if ($this->attributes['type'] != 'site') {
         $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class()));
         throw new InvalidClassException($msg);
     }
     // Load missing data
     $row = get_site_entity_as_row($guid);
     if ($row && !$this->isFullyLoaded()) {
         // If $row isn't a cached copy then increment the counter
         $this->attributes['tables_loaded']++;
     }
     // Now put these into the attributes array as core values
     $objarray = (array) $row;
     foreach ($objarray as $key => $value) {
         $this->attributes[$key] = $value;
     }
     return true;
 }
Пример #2
0
 /**
  * Loads the full ElggSite when given a guid.
  *
  * @param mixed $guid GUID of ElggSite entity or database row object
  *
  * @return bool
  * @throws InvalidClassException
  */
 protected function load($guid)
 {
     // Test to see if we have the generic stuff
     if (!parent::load($guid)) {
         return false;
     }
     // Only work with GUID from here
     if ($guid instanceof stdClass) {
         $guid = $guid->guid;
     }
     // Check the type
     if ($this->attributes['type'] != 'site') {
         $msg = elgg_echo('InvalidClassException:NotValidElggStar', array($guid, get_class()));
         throw new InvalidClassException($msg);
     }
     // Load missing data
     $row = get_site_entity_as_row($guid);
     if ($row && !$this->isFullyLoaded()) {
         // If $row isn't a cached copy then increment the counter
         $this->attributes['tables_loaded']++;
     }
     // Now put these into the attributes array as core values
     $objarray = (array) $row;
     foreach ($objarray as $key => $value) {
         $this->attributes[$key] = $value;
     }
     // guid needs to be an int  http://trac.elgg.org/ticket/4111
     $this->attributes['guid'] = (int) $this->attributes['guid'];
     return true;
 }