/** * Gets all the translations for the provided locale * @param string $localeCode code of the locale * @return array an associative array with translation key - value pairs */ public function getTranslations($localeCode) { if (isset($this->translations[$localeCode])) { return $this->translations[$localeCode]; } $this->translations[$localeCode] = $this->cache->get(self::CACHE_TYPE, $localeCode); if ($this->translations[$localeCode]) { return $this->translations[$localeCode]; } $this->translations[$localeCode] = $this->io->getAllTranslations($localeCode); $this->cache->set(self::CACHE_TYPE, $localeCode, $this->translations[$localeCode]); return $this->translations[$localeCode]; }
public function testReadAllWithCache() { $this->io->setIsCacheEnabled(true); $this->cache->get(self::ENVIRONMENT_NAME, 'file'); $expected = array('file' => array('another_key' => 'another_value'), 'only_in_cache' => array('test' => '123'), 'only_in_config' => array('foo' => 'bar')); $actual = $this->io->readAll(); $this->assertEquals($expected, $actual); }
/** * Get the names of all the sections in the configuration * * @return array Array with the names of of all the sections in the configuration */ public function getAllSections() { if (!$this->isCacheEnabled()) { return $this->configIO->getAllSections(); } $all = $this->cache->get($this->cacheType); $sections = array_merge(array_keys($all), $this->configIO->getAllSections()); $sections = array_unique($sections); return array_values($sections); }