Example #1
0
 /**
  * Loads the default configuration for the current application.
  *
  * @uses Config::loadFile()
  * @throws \Exception if any extension is not found
  * @return array loaded configuration
  */
 public static function load()
 {
     $tConfigFiles = array(Framework::$corepath . 'config.json');
     if (Framework::$application !== null) {
         Io::glob(Framework::$application->path . 'config/', '*.json', Io::GLOB_RECURSIVE | Io::GLOB_FILES, "", $tConfigFiles);
     }
     $tLastModified = Io::getLastModified($tConfigFiles);
     $tOutputFile = Io::translatePath('{writable}cache/config');
     if (!Framework::$disableCaches && Io::isReadableAndNewer($tOutputFile, $tLastModified)) {
         self::$loadedFromCache = true;
         return Io::readSerialize($tOutputFile);
     }
     $tConfig = array();
     foreach ($tConfigFiles as $tFile) {
         self::loadFile($tConfig, $tFile, true);
     }
     if (isset($tConfig['extensionList'])) {
         foreach ($tConfig['extensionList'] as $tExtension) {
             $tFile = Framework::$corepath . 'src/Scabbia/Extensions/' . $tExtension . '/config.json';
             if (file_exists($tFile)) {
                 self::loadFile($tConfig, $tFile, false);
                 continue;
             }
             if (Framework::$application !== null) {
                 $tFile = Framework::$application->path . 'Extensions/' . $tExtension . '/config.json';
                 if (file_exists($tFile)) {
                     self::loadFile($tConfig, $tFile, false);
                     continue;
                 }
             }
             throw new \Exception('extension not found - ' . $tExtension);
         }
     }
     self::$loadedFromCache = false;
     if (!Framework::$readonly) {
         Io::writeSerialize($tOutputFile, $tConfig);
     }
     return $tConfig;
 }