| @@ -11,75 +11,75 @@ | ||
| 11 | 11 | |
| 12 | 12 | class YamlConfigurationServiceProvider implements ServiceProviderInterface | 
| 13 | 13 |  { | 
| 14 | - protected $cacheDirPath; | |
| 15 | - protected $configFilePath; | |
| 16 | - protected $debug; | |
| 14 | + protected $cacheDirPath; | |
| 15 | + protected $configFilePath; | |
| 16 | + protected $debug; | |
| 17 | 17 | |
| 18 | - protected $configCacheFactory; | |
| 18 | + protected $configCacheFactory; | |
| 19 | 19 | |
| 20 | - public function __construct($configFilePath, $options = null) | |
| 21 | -    { | |
| 22 | - $this->debug = $app['debug']; | |
| 20 | + public function __construct($configFilePath, $options = null) | |
| 21 | +	{ | |
| 22 | + $this->debug = $app['debug']; | |
| 23 | 23 | |
| 24 | -        if (is_array($options)) { | |
| 24 | +		if (is_array($options)) { | |
| 25 | 25 | |
| 26 | -            if (isset($options['cache_dir'])) { | |
| 27 | - $this->cacheDirPath = $options['cache_dir']; | |
| 28 | - } | |
| 26 | +			if (isset($options['cache_dir'])) { | |
| 27 | + $this->cacheDirPath = $options['cache_dir']; | |
| 28 | + } | |
| 29 | 29 | |
| 30 | -            if (isset($options['debug'])) { | |
| 31 | - $this->debug = $options['debug']; | |
| 32 | - } | |
| 30 | +			if (isset($options['debug'])) { | |
| 31 | + $this->debug = $options['debug']; | |
| 32 | + } | |
| 33 | 33 | |
| 34 | - } | |
| 34 | + } | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | - $this->configFilePath = $configFilePath; | |
| 38 | - } | |
| 37 | + $this->configFilePath = $configFilePath; | |
| 38 | + } | |
| 39 | 39 | |
| 40 | - public function register(Application $app) | |
| 41 | -    { | |
| 42 | -        $app['config'] = $app->share(function () { | |
| 43 | -            if ($this->cacheDirPath) { | |
| 44 | - $cache = $this->getConfigCacheFactory($this->debug)->cache($this->cacheDirPath.'/config.cache.php', | |
| 45 | -                    function (ConfigCacheInterface $cache) { | |
| 46 | - $config = $this->loadConfig(); | |
| 40 | + public function register(Application $app) | |
| 41 | +	{ | |
| 42 | +		$app['config'] = $app->share(function () { | |
| 43 | +			if ($this->cacheDirPath) { | |
| 44 | + $cache = $this->getConfigCacheFactory($this->debug)->cache($this->cacheDirPath.'/config.cache.php', | |
| 45 | +					function (ConfigCacheInterface $cache) { | |
| 46 | + $config = $this->loadConfig(); | |
| 47 | 47 | |
| 48 | -                        $content = sprintf('<?php use Junker\Silex\Config; $c = new Config(%s);', var_export($config->data, true)).PHP_EOL; | |
| 49 | - $content .= 'return $c;'; | |
| 48 | +						$content = sprintf('<?php use Junker\Silex\Config; $c = new Config(%s);', var_export($config->data, true)).PHP_EOL; | |
| 49 | + $content .= 'return $c;'; | |
| 50 | 50 | |
| 51 | - $cache->write($content, $config->getResources()); | |
| 52 | - } | |
| 53 | - ); | |
| 51 | + $cache->write($content, $config->getResources()); | |
| 52 | + } | |
| 53 | + ); | |
| 54 | 54 | |
| 55 | - $config = include $cache->getPath(); | |
| 56 | -            } else { | |
| 57 | - $config = $this->loadConfig(); | |
| 58 | - } | |
| 55 | + $config = include $cache->getPath(); | |
| 56 | +			} else { | |
| 57 | + $config = $this->loadConfig(); | |
| 58 | + } | |
| 59 | 59 | |
| 60 | - return $config->data; | |
| 61 | - }); | |
| 62 | - } | |
| 60 | + return $config->data; | |
| 61 | + }); | |
| 62 | + } | |
| 63 | 63 | |
| 64 | - public function boot(Application $app) | |
| 65 | -    { | |
| 66 | - } | |
| 64 | + public function boot(Application $app) | |
| 65 | +	{ | |
| 66 | + } | |
| 67 | 67 | |
| 68 | - private function getConfigCacheFactory($debug = false) | |
| 69 | -    { | |
| 70 | -        if ($this->configCacheFactory === null) { | |
| 71 | - $this->configCacheFactory = new ConfigCacheFactory($debug); | |
| 72 | - } | |
| 68 | + private function getConfigCacheFactory($debug = false) | |
| 69 | +	{ | |
| 70 | +		if ($this->configCacheFactory === null) { | |
| 71 | + $this->configCacheFactory = new ConfigCacheFactory($debug); | |
| 72 | + } | |
| 73 | 73 | |
| 74 | - return $this->configCacheFactory; | |
| 75 | - } | |
| 74 | + return $this->configCacheFactory; | |
| 75 | + } | |
| 76 | 76 | |
| 77 | - protected function loadConfig() | |
| 78 | -    { | |
| 79 | - $loader = new YamlFileLoader(new FileLocator(dirname($this->configFilePath))); | |
| 77 | + protected function loadConfig() | |
| 78 | +	{ | |
| 79 | + $loader = new YamlFileLoader(new FileLocator(dirname($this->configFilePath))); | |
| 80 | 80 | |
| 81 | - $config = $loader->load($this->configFilePath); | |
| 81 | + $config = $loader->load($this->configFilePath); | |
| 82 | 82 | |
| 83 | - return $config; | |
| 84 | - } | |
| 83 | + return $config; | |
| 84 | + } | |
| 85 | 85 | } |