protected function i18n_string_textgroup_default::multiple_cache_get in Internationalization 7
Get strings from multiple cache.
Parameters
$context array: String context as array with language property at the end.
Return value
mixed Array of strings (may be empty) if we've got a cache hit. Null otherwise.
2 calls to i18n_string_textgroup_default::multiple_cache_get()
- i18n_string_textgroup_cached::multiple_cache_get in i18n_string/
i18n_string.inc  - Get strings from multiple cache.
 - i18n_string_textgroup_default::multiple_translation_search in i18n_string/
i18n_string.inc  - Search multiple translations with key combinations.
 
1 method overrides i18n_string_textgroup_default::multiple_cache_get()
- i18n_string_textgroup_cached::multiple_cache_get in i18n_string/
i18n_string.inc  - Get strings from multiple cache.
 
File
- i18n_string/
i18n_string.inc, line 996  - API for internationalization strings
 
Class
- i18n_string_textgroup_default
 - Textgroup handler for i18n_string API
 
Code
protected function multiple_cache_get($context) {
  $cache_key = implode(':', $context);
  if (isset($this->cache_multiple[$cache_key])) {
    return $this->cache_multiple[$cache_key];
  }
  else {
    // Now we try more generic keys. For instance, if we are searching 'term:1:*'
    // we may try too 'term:*:*' and filter out the results.
    foreach ($context as $key => $value) {
      if ($value != '*') {
        $try = array_merge($context, array(
          $key => '*',
        ));
        $cache_key = implode(':', $try);
        if (isset($this->cache_multiple[$cache_key])) {
          // As we've found some more generic key, we need to filter using original conditions.
          $strings = $this
            ->string_filter($this->cache_multiple[$cache_key], $context);
          return $strings;
        }
      }
    }
    // If we've reached here, we didn't find any cache match.
    return NULL;
  }
}