Remove useless cache.paths services, use cache.path instead

This commit is contained in:
Benoît Burnichon
2015-04-14 15:23:35 +02:00
parent 05639e0953
commit 0349db4adb
4 changed files with 25 additions and 50 deletions

View File

@@ -719,20 +719,8 @@ class Application extends SilexApplication
// thumbnails path
$this['thumbnail.path'] = $dir = $this['root.path'].'/www/thumbnails';
// cache path for dev env
$this['cache.dev.path'] = $this->share(function() {
$path = sys_get_temp_dir().'/'.md5($this['root.path']);
// ensure path is created
$this['filesystem']->mkdir($path);
return $path;
});
// cache path (twig, minify, translations, configuration, doctrine metas serializer metas, profiler etc ...)
$this['cache.path'] = $this->share(function() {
// if ($this->getEnvironment() !== Application::ENV_PROD) {
// return $this['cache.dev.path'];
// }
$defaultPath = $path = $this['root.path'].'/cache';
if ($this['phraseanet.configuration']->isSetup()) {
$path = $this['conf']->get(['main', 'storage', 'cache'], $path);
@@ -745,14 +733,6 @@ class Application extends SilexApplication
return $path;
});
$this['cache.paths'] = $this->share(function() {
return array(
self::ENV_DEV => $this['cache.path'],
self::ENV_TEST => $this['cache.path'],
self::ENV_PROD => $this['cache.path']
);
});
// log path
$this['log.path'] = $this->share(function() {
$defaultPath = $path = $this['root.path'].'/logs';

View File

@@ -65,25 +65,24 @@ class Uninstaller extends Command
}
}
foreach ($this->container['cache.paths'] as $path) {
foreach ([
$path.'/cache_registry.php',
$path.'/cache_registry.yml',
$path.'/serializer',
$path.'/doctrine',
$path.'/twig',
$path.'/translations',
$path.'/minify',
$path.'/profiler',
] as $resource) {
if (is_dir($resource)) {
$finder = new Finder();
foreach ($finder->files()->in($resource) as $file) {
$this->container['filesystem']->remove($file);
}
} elseif (is_file($resource)) {
$this->container['filesystem']->remove($resource);
$path = $this->container['cache.path'];
foreach ([
$path.'/cache_registry.php',
$path.'/cache_registry.yml',
$path.'/serializer',
$path.'/doctrine',
$path.'/twig',
$path.'/translations',
$path.'/minify',
$path.'/profiler',
] as $resource) {
if (is_dir($resource)) {
$finder = new Finder();
foreach ($finder->files()->in($resource) as $file) {
$this->container['filesystem']->remove($file);
}
} elseif (is_file($resource)) {
$this->container['filesystem']->remove($resource);
}
}

View File

@@ -273,14 +273,13 @@ class appbox extends base
$finder = new Finder();
$in = [];
foreach ($app['cache.paths'] as $path) {
$in[] = $path.'/minify/';
$in[] = $path.'/twig/';
$in[] = $path.'/translations/';
$in[] = $path.'/profiler/';
$in[] = $path.'/doctrine/';
$in[] = $path.'/serializer/';
};
$path = $app['cache.path'];
$in[] = $path.'/minify/';
$in[] = $path.'/twig/';
$in[] = $path.'/translations/';
$in[] = $path.'/profiler/';
$in[] = $path.'/doctrine/';
$in[] = $path.'/serializer/';
$finder->in(array_filter($in, function($path) {
return is_dir($path);
}))

View File

@@ -31,10 +31,7 @@ class module_console_systemClearCache extends Command
{
$finder = new Finder();
$in = [];
foreach ($this->container['cache.paths'] as $path) {
$in[] = $path;
};
$in = $this->container['cache.path'];
$finder
->exclude('.git')
->exclude('.svn')