示例#1
0
 function getConf($name)
 {
     $name = $this->_normalizeConfName($name);
     if (isset($this->confs[$name])) {
         return $this->confs[$name];
     }
     $ext = substr($name, strpos($name, '.'));
     if ($ext == '.ini') {
         $file = $this->_locateConfFiles($name);
         if (LIMB_APP_PRODUCTION == lmb_app_mode() && lmb_env_has('LIMB_VAR_DIR')) {
             $this->confs[$name] = new lmbCachedIni($file, lmb_env_get('LIMB_VAR_DIR') . '/ini/');
         } else {
             $this->confs[$name] = new lmbIni($file);
         }
     } elseif ($ext == '.yml') {
         $file = $this->_locateConfFiles($name);
         $this->confs[$name] = $this->parseYamlFile(lmbFs::normalizePath($file));
     } elseif ($ext == '.conf.php') {
         $file = $this->_locateConfFiles($name);
         if (!count($file)) {
             throw new lmbFileNotFoundException($name);
         }
         $this->confs[$name] = new lmbConf(lmbFs::normalizePath($file));
     } else {
         throw new lmbException("'{$ext}' type configuration is not supported!");
     }
     return $this->confs[$name];
 }
示例#2
0
 function getFileLocator($paths, $locator_name = null)
 {
     if (!$locator_name) {
         $locator_name = md5($paths);
     }
     if (isset($this->file_locators[$locator_name])) {
         return $this->file_locators[$locator_name];
     }
     if (is_array($paths)) {
         $file_locations = new lmbIncludePathFileLocations($paths);
     } else {
         $file_locations = new lmbIncludePathFileLocations(explode(';', $paths));
     }
     if (lmb_env_has('LIMB_VAR_DIR') && LIMB_APP_PRODUCTION == lmb_app_mode()) {
         $locator = new lmbCachingFileLocator(new lmbFileLocator($file_locations), lmb_env_get('LIMB_VAR_DIR') . '/locators/', $locator_name);
     } else {
         $locator = new lmbFileLocator($file_locations);
     }
     $this->file_locators[$locator_name] = $locator;
     return $locator;
 }
示例#3
0
 function isCacheEnabled()
 {
     return LIMB_APP_PRODUCTION == lmb_app_mode();
 }
 function testLmbAppMode()
 {
     $old_value = lmb_env_get('LIMB_APP_MODE');
     lmb_env_set('LIMB_APP_MODE', LIMB_APP_PRODUCTION);
     $this->assertIdentical(LIMB_APP_PRODUCTION, lmb_app_mode());
     lmb_app_mode(LIMB_APP_DEVELOPMENT);
     $this->assertIdentical(LIMB_APP_DEVELOPMENT, lmb_app_mode());
     lmb_env_set('LIMB_APP_MODE', $old_value);
 }