/** * Returns a array containing the translation map for the specified * $locale and $context. * * It uses the $tsLocationPath and * $tsFilenameFormat properties to locate the file, unless caching is * enabled. If a cache object is available it will be used to retrieve the * information from the cache. * * @throws ezcTranslationContextNotAvailableException if the context is not available. * @param string $locale * @param string $context * @return array(ezcTranslationData) */ public function getContext($locale, $context) { $cachedContext = $this->cache->restore("{$locale}/{$context}"); if ($cachedContext === false) { throw new ezcTranslationContextNotAvailableException($context); } foreach ($cachedContext as $key => $cachedElement) { if ($cachedElement->status == ezcTranslationData::OBSOLETE) { unset($cachedContext[$key]); } } return $cachedContext; }
public function testRestoreWithoutSearch() { $cache = new ezcCacheStorageFileArray($this->createTempDir('ezcCacheStorageFileTest'), array('extension' => '.c', 'ttl' => false)); $id = "test"; $keys = array(10000, 1, 10, 100, 1000); // Store foreach ($keys as $key) { // No cache may exist! $this->assertFalse($cache->restore($id, array(0 => $key, 1 => "en"), false)); $cache->store($id, "ID={$key}&LANG=en", array(0 => $key, 1 => "en")); } // Restore foreach ($keys as $key) { $this->assertEquals($cache->restore($id, array(0 => $key, 1 => "en"), false), "ID={$key}&LANG=en"); } $this->removeTempDir(); }