You are here

protected function i18n_string_object::rebuild_from_cache in Internationalization 7

Rebuild the object data based on the persistent cache.

Since the textgroup defines if a string is cacheable or not the caching of the string objects happens in the textgroup handler itself.

See also

i18n_string_textgroup_cached::__destruct()

2 calls to i18n_string_object::rebuild_from_cache()
i18n_string_object::set_context in i18n_string/i18n_string.inc
Set context properties
i18n_string_object::__construct in i18n_string/i18n_string.inc
Class constructor

File

i18n_string/i18n_string.inc, line 54
API for internationalization strings

Class

i18n_string_object
String object that contains source and translations.

Code

protected function rebuild_from_cache($data = NULL) {

  // Check if we've the required information to repopulate the cache and do so
  // if possible.
  $meta_data_exist = isset($this->textgroup) && isset($this->type) && isset($this->objectid) && isset($this->property);
  if ($meta_data_exist && ($cache = cache_get($this
    ->get_cid())) && !empty($cache->data)) {

    // Re-spawn the cached data.
    // @TODO do we need a array_diff to ensure we don't overwrite the data
    // provided by the $data parameter?
    $this
      ->set_properties($cache->data);
  }
}