Example #1
0
 /**
  * Get a merged array of default and overriden config
  * @return array
  */
 public function all()
 {
     $defaultConfig = $this->getDefaultConfig();
     $userConfig = array_dot($this->config);
     $config = $userConfig + $defaultConfig;
     return array_undot($config);
 }
Example #2
0
 function array_undot($array)
 {
     $results = array();
     foreach ($array as $key => $value) {
         $dot = strpos($key, '.');
         if ($dot === false) {
             $results[$key] = $value;
         } else {
             list($first, $second) = explode('.', $key, 2);
             if (!isset($results[$first])) {
                 $results[$first] = array();
             }
             $results[$first][$second] = $value;
         }
     }
     return array_map(function ($value) {
         return is_string($value) ? $value : array_undot($value);
     }, $results);
 }
Example #3
0
 /**
  * Get translations from subfolders.
  *
  * @return array
  */
 private function fireSubDir($localeDir, $langDirectory, $locale)
 {
     $array = array();
     $allFiles = $this->finder->allFiles($langDirectory);
     foreach ($allFiles as $file) {
         $filePathname = $file->getPathname();
         $relativePath = $file->getRelativePath();
         $dirGroup = str_replace(array($localeDir . DIRECTORY_SEPARATOR, '.php'), '', $filePathname);
         $fileGroup = str_replace(array($langDirectory . DIRECTORY_SEPARATOR, '.php'), '', $filePathname);
         $lines = $this->fileLoader->loadRawLocale($locale, $dirGroup);
         if (empty($relativePath)) {
             $lines = $this->fileLoader->loadRawLocale($locale, $dirGroup);
             $array = array_merge($array, array($fileGroup => $lines));
         } else {
             $lines = $this->fileLoader->loadRawLocale($locale, $dirGroup);
             $fileDot = str_replace(DIRECTORY_SEPARATOR, '.', $fileGroup);
             $array = array_merge_recursive($array, array_undot(array($fileDot => $lines)));
         }
     }
     return $array;
 }