Exemple #1
0
 /**
  * Initialise the attributes array. 
  * This is vital to distinguish between metadata and base parameters.
  * 
  * Place your base parameters here.
  * 
  * @return void
  */
 protected function initialise_attributes()
 {
     initialise_entity_cache();
     // Create attributes array if not already created
     if (!is_array($this->attributes)) {
         $this->attributes = array();
     }
     if (!is_array($this->temp_metadata)) {
         $this->temp_metadata = array();
     }
     if (!is_array($this->temp_annotations)) {
         $this->temp_annotations = array();
     }
     if (!is_array($this->volatile)) {
         $this->volatile = array();
     }
     $this->attributes['guid'] = "";
     $this->attributes['type'] = "";
     $this->attributes['subtype'] = "";
     $this->attributes['owner_guid'] = get_loggedin_userid();
     $this->attributes['container_guid'] = get_loggedin_userid();
     $this->attributes['site_guid'] = 0;
     $this->attributes['access_id'] = ACCESS_PRIVATE;
     $this->attributes['time_created'] = "";
     $this->attributes['time_updated'] = "";
     $this->attributes['enabled'] = "yes";
     // There now follows a bit of a hack
     /* Problem: To speed things up, some objects are split over several tables, this means that it requires
      * n number of database reads to fully populate an entity. This causes problems for caching and create events
      * since it is not possible to tell whether a subclassed entity is complete.
      * Solution: We have two counters, one 'tables_split' which tells whatever is interested how many tables 
      * are going to need to be searched in order to fully populate this object, and 'tables_loaded' which is how
      * many have been loaded thus far.
      * If the two are the same then this object is complete.
      * 
      * Use: isFullyLoaded() to check
      */
     $this->attributes['tables_split'] = 1;
     $this->attributes['tables_loaded'] = 0;
 }
 public function testElggEntityCache()
 {
     global $ENTITY_CACHE;
     $ENTITY_CACHE = NULL;
     $this->assertNull($ENTITY_CACHE);
     initialise_entity_cache();
     $this->assertIsA($ENTITY_CACHE, 'array');
 }