/**
  * @param string $appPath
  * @param string $env
  *
  * @return CompiledContainer
  */
 public static function getContainer($appPath, $env = null)
 {
     static::$appPath = $appPath;
     static::$cachePath = $appPath . '/app/cache';
     static::$configPath = $appPath . '/app/config';
     $containerCacheFile = static::$cachePath . '/container.php';
     $containerConfigCache = new ConfigCache($containerCacheFile, $env != 'prod');
     if (!$containerConfigCache->isFresh()) {
         $containerBuilder = static::buildContainer();
         $dumper = new PhpDumper($containerBuilder);
         $containerConfigCache->write($dumper->dump(array('class' => 'CompiledContainer')), $containerBuilder->getResources());
     }
     require_once $containerCacheFile;
     $container = new CompiledContainer();
     return $container;
 }
 /**
  * Load
  * @param $basePath
  * @param bool|false $enableCache
  * @param array $options
  */
 public static function load($basePath, $enableCache = false, $options = [])
 {
     static::$basePath = $basePath;
     static::$configPath = __DIR__ . '/config';
     static::$appConfigPath = static::$basePath . '/' . static::$configDir;
     static::$enableCache = $enableCache;
     if ($options && $options['cacheDuration']) {
         static::$cacheDuration = (int) $options['cacheDuration'];
     }
     if ($options && $options['cacheDir']) {
         static::$cacheDir = (string) $options['cacheDir'];
     }
     if (static::$enableCache) {
         static::$cache = new FileCache(['cachePath' => $basePath . '/' . static::$cacheDir]);
     }
     if (!is_dir(static::$appConfigPath)) {
         \yii\helpers\FileHelper::createDirectory(static::$appConfigPath);
     }
     static::loadMainConfig();
 }
示例#3
0
文件: Config.php 项目: Golpha/Config
 /**
  * sets the used config path.
  *
  * @param $path
  */
 public static function setConfigDirectory($path)
 {
     static::$configPath = $path;
 }
示例#4
0
 /**
  * Change config path (useful for tests)
  * @param $configPath
  */
 public static function setConfigPath($configPath)
 {
     static::$configPath = $configPath;
 }