Fix clear cache, update storage paths

This commit is contained in:
Samuel Georges 2015-02-07 14:50:03 +11:00
parent 0990487359
commit 9a616b6174
11 changed files with 67 additions and 32 deletions

View File

@ -9,12 +9,13 @@ $writablePaths = [
$uploadsDir, $uploadsDir,
$uploadsDir.'/public', $uploadsDir.'/public',
$uploadsDir.'/protected', $uploadsDir.'/protected',
'/app/storage', '/storage',
'/app/storage/logs', '/storage/logs',
'/app/storage/cache', '/storage/framework',
'/app/storage/twig', '/storage/cms',
'/app/storage/meta', '/storage/cms/cache',
'/app/storage/combiner', '/storage/cms/twig',
'/storage/cms/combiner',
]; ];
$requiredExtensions = [ $requiredExtensions = [
'GD' => extension_loaded('gd'), 'GD' => extension_loaded('gd'),

View File

@ -174,7 +174,7 @@ class CodeParser
protected function getFilePath() protected function getFilePath()
{ {
$hash = abs(crc32($this->filePath)); $hash = abs(crc32($this->filePath));
$result = storage_path().'/cache/'; $result = storage_path().'/cms/cache/';
$result .= substr($hash, 0, 2).'/'; $result .= substr($hash, 0, 2).'/';
$result .= substr($hash, 2, 2).'/'; $result .= substr($hash, 2, 2).'/';
$result .= basename($this->filePath).'.php'; $result .= basename($this->filePath).'.php';

View File

@ -361,7 +361,7 @@ class Controller
'debug' => $isDebugMode, 'debug' => $isDebugMode,
]; ];
if (!Config::get('cms.twigNoCache')) { if (!Config::get('cms.twigNoCache')) {
$options['cache'] = storage_path().'/twig'; $options['cache'] = storage_path().'/cms/twig';
} }
$this->twig = new Twig_Environment($this->loader, $options); $this->twig = new Twig_Environment($this->loader, $options);

View File

@ -38,11 +38,6 @@ class ServiceProvider extends ModuleServiceProvider
*/ */
parent::register('system'); parent::register('system');
/*
* Register core providers
*/
// App::register('October\Rain\Translation\TranslationServiceProvider');
/* /*
* Define path constants * Define path constants
*/ */
@ -121,7 +116,7 @@ class ServiceProvider extends ModuleServiceProvider
/* /*
* Register basic Twig * Register basic Twig
*/ */
App::bindShared('twig', function ($app) { App::singleton('twig', function ($app) {
$twig = new Twig_Environment(new TwigLoader(), ['auto_reload' => true]); $twig = new Twig_Environment(new TwigLoader(), ['auto_reload' => true]);
$twig->addExtension(new TwigExtension); $twig->addExtension(new TwigExtension);
return $twig; return $twig;
@ -137,7 +132,7 @@ class ServiceProvider extends ModuleServiceProvider
/* /*
* Register Twig that will parse strings * Register Twig that will parse strings
*/ */
App::bindShared('twig.string', function ($app) { App::singleton('twig.string', function ($app) {
$twig = $app['twig']; $twig = $app['twig'];
$twig->setLoader(new Twig_Loader_String); $twig->setLoader(new Twig_Loader_String);
return $twig; return $twig;
@ -321,6 +316,13 @@ class ServiceProvider extends ModuleServiceProvider
]); ]);
}); });
/*
* Override clear cache command
*/
App::singleton('command.cache.clear', function ($app) {
return new \System\Console\CacheClear($app['cache'], $app['files']);
});
/* /*
* Register console commands * Register console commands
*/ */
@ -332,13 +334,6 @@ class ServiceProvider extends ModuleServiceProvider
$this->registerConsoleCommand('plugin.remove', 'System\Console\PluginRemove'); $this->registerConsoleCommand('plugin.remove', 'System\Console\PluginRemove');
$this->registerConsoleCommand('plugin.refresh', 'System\Console\PluginRefresh'); $this->registerConsoleCommand('plugin.refresh', 'System\Console\PluginRefresh');
/*
* Override clear cache command
*/
App::bindShared('command.cache.clear', function ($app) {
return new \System\Console\CacheClear($app['cache'], $app['files']);
});
/* /*
* Register the sidebar for the System main menu * Register the sidebar for the System main menu
*/ */

View File

@ -171,7 +171,7 @@ class CombineAssets
} }
$this->path = $cacheInfo['path']; $this->path = $cacheInfo['path'];
$this->storagePath = storage_path().'/combiner/cms'; $this->storagePath = storage_path().'/cms/combiner';
$combiner = $this->prepareCombiner($cacheInfo['files']); $combiner = $this->prepareCombiner($cacheInfo['files']);
$contents = $combiner->dump(); $contents = $combiner->dump();
@ -278,7 +278,7 @@ class CombineAssets
} }
$this->path = public_path().$path; $this->path = public_path().$path;
$this->storagePath = storage_path().'/combiner/cms'; $this->storagePath = storage_path().'/cms/combiner';
list($assets, $extension) = $this->prepareAssets($assets); list($assets, $extension) = $this->prepareAssets($assets);

View File

@ -49,7 +49,7 @@ class PluginManager
/** /**
* @var string Path to the disarm file. * @var string Path to the disarm file.
*/ */
protected $metaPath; protected $metaFile;
/** /**
* @var array Collection of disabled plugins * @var array Collection of disabled plugins
@ -67,7 +67,7 @@ class PluginManager
protected function init() protected function init()
{ {
$this->app = App::make('app'); $this->app = App::make('app');
$this->metaPath = Config::get('app.manifest'); $this->metaFile = storage_path() . '/cms/disabled.json';
$this->loadDisabled(); $this->loadDisabled();
$this->loadPlugins(); $this->loadPlugins();
$this->loadDependencies(); $this->loadDependencies();
@ -369,7 +369,7 @@ class PluginManager
public function clearDisabledCache() public function clearDisabledCache()
{ {
File::delete($this->metaPath.'/disabled.json'); File::delete($this->metaFile);
$this->disabledPlugins = []; $this->disabledPlugins = [];
} }
@ -378,7 +378,7 @@ class PluginManager
*/ */
protected function loadDisabled() protected function loadDisabled()
{ {
$path = $this->metaPath.'/disabled.json'; $path = $this->metaFile;
if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) { if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) {
foreach ($configDisabled as $disabled) { foreach ($configDisabled as $disabled) {
@ -413,7 +413,7 @@ class PluginManager
*/ */
protected function writeDisabled() protected function writeDisabled()
{ {
$path = $this->metaPath.'/disabled.json'; $path = $this->metaFile;
File::put($path, json_encode($this->disabledPlugins)); File::put($path, json_encode($this->disabledPlugins));
} }

View File

@ -4,14 +4,39 @@ use App;
use Config; use Config;
use Illuminate\Cache\Console\ClearCommand; use Illuminate\Cache\Console\ClearCommand;
use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Output\NullOutput;
use Illuminate\Cache\CacheManager;
use Illuminate\Filesystem\Filesystem;
class CacheClear extends ClearCommand class CacheClear extends ClearCommand
{ {
/**
* The file system instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;
/**
* Create a new cache clear command instance.
*
* @param \Illuminate\Cache\CacheManager $cache
* @param \Illuminate\Filesystem\Filesystem $files
* @return void
*/
public function __construct(CacheManager $cache, Filesystem $files)
{
parent::__construct($cache);
$this->files = $files;
}
/** /**
* Execute the console command. * Execute the console command.
*/ */
public function fire() public function fire()
{ {
$storagePath = $this->laravel->storagePath();
/* /*
* Allow this command to be executed internally * Allow this command to be executed internally
*/ */
@ -22,16 +47,24 @@ class CacheClear extends ClearCommand
/* /*
* Combiner * Combiner
*/ */
foreach ($this->files->directories(storage_path().'/combiner') as $directory) { foreach ($this->files->directories($storagePath.'/cms/combiner') as $directory) {
$this->files->deleteDirectory($directory); $this->files->deleteDirectory($directory);
} }
$this->info('Combiner cache cleared!'); $this->info('Combiner cache cleared!');
/*
* Combiner
*/
foreach ($this->files->directories($storagePath.'/cms/cache') as $directory) {
$this->files->deleteDirectory($directory);
}
$this->info('CMS cache cleared!');
/* /*
* Twig * Twig
*/ */
if (!Config::get('cms.twigNoCache')) { if (!Config::get('cms.twigNoCache')) {
foreach ($this->files->directories(storage_path().'/twig') as $directory) { foreach ($this->files->directories($storagePath.'/cms/twig') as $directory) {
$this->files->deleteDirectory($directory); $this->files->deleteDirectory($directory);
} }
$this->info('Twig cache cleared!'); $this->info('Twig cache cleared!');
@ -40,7 +73,7 @@ class CacheClear extends ClearCommand
/* /*
* Meta * Meta
*/ */
$this->files->delete($this->laravel['config']['app.manifest'].'/disabled.json'); $this->files->delete($storagePath.'/cms/disabled.json');
parent::fire(); parent::fire();
} }

6
storage/cms/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
config.php
routes.php
compiled.php
services.json
events.scanned.php
routes.scanned.php