Skip to content

Commit

Permalink
Moving out the storage folder
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhicetea committed Apr 9, 2016
1 parent 9d75658 commit 474fbe3
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Sifoni/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -155,23 +166,27 @@ 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']) {
$app->register(new WhoopsServiceProvider());

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,
));
}
}
Expand Down

0 comments on commit 474fbe3

Please sign in to comment.