From 474fbe33f4aab2fefc7a3be6a67dfdbae8ea96cd Mon Sep 17 00:00:00 2001 From: KhanhIceTea Date: Sun, 10 Apr 2016 00:55:44 +0700 Subject: [PATCH] Moving out the storage folder --- src/Sifoni/Engine.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Sifoni/Engine.php b/src/Sifoni/Engine.php index c0ffc3f..88188df 100644 --- a/src/Sifoni/Engine.php +++ b/src/Sifoni/Engine.php @@ -15,6 +15,7 @@ use Silex\Provider\WebProfilerServiceProvider; use Sifoni\Provider\CapsuleServiceProvider; use Sifoni\Provider\WhoopsServiceProvider; +use Monolog\Logger; class Engine { const ENV_DEV = 'DEV'; @@ -89,6 +90,7 @@ public function bootstrap(array $new_options = array()) { 'enabled_http_cache' => false, 'http_cache' => false, 'dir.app' => 'app', + 'dir.storage' => 'storage', 'dir.config' => 'config', 'dir.cache' => 'cache', 'dir.log' => 'log', @@ -117,6 +119,15 @@ public function getDirPath($name) { return $this->app['path.root'] . DS . $this->app['dir.app'] . DS . $dir_name; } + /** + * @param $name + * @return string + */ + public function getStoragePath($name) { + $dir_name = isset($this->app['dir.' . $name]) ? $this->app['dir.' . $name] : $name; + return $this->app['path.root'] . DS . $this->app['dir.storage'] . DS . $dir_name; + } + /** * @param $file_name * @throws Exception @@ -155,7 +166,7 @@ private function registerServices() { )); $app->register(new CapsuleServiceProvider(), $app['config.database.parameters']); $app->register(new MonologServiceProvider(), array( - 'monolog.logfile' => $this->getDirPath('log') . DS . ($app['debug'] ? 'debug.log' : 'production.log'), + 'monolog.logfile' => $this->getStoragePath('log') . DS . ($app['debug'] ? 'debug.log' : 'production.log'), )); if ($app['debug']) { @@ -163,15 +174,19 @@ private function registerServices() { if ($app['web_profiler']) { $app->register(new WebProfilerServiceProvider(), array( - 'profiler.cache_dir' => $this->getDirPath('cache') . DS . 'profiler' . DS, + 'profiler.cache_dir' => $this->getStoragePath('cache') . DS . 'profiler' . DS, 'profiler.mount_prefix' => '/_profiler', )); } + } else { + $app['monolog.level'] = function () { + return Logger::ERROR; + }; } if ($app['enabled_http_cache']) { $app->register(new HttpCacheServiceProvider(), array( - 'http_cache.cache_dir' => $this->getDirPath('cache') . DS, + 'http_cache.cache_dir' => $this->getStoragePath('cache') . DS, )); } }