diff --git a/modules/backend/controllers/index/_warnings.htm b/modules/backend/controllers/index/_warnings.htm index 1723638ad..5a058d578 100644 --- a/modules/backend/controllers/index/_warnings.htm +++ b/modules/backend/controllers/index/_warnings.htm @@ -9,12 +9,13 @@ $writablePaths = [ $uploadsDir, $uploadsDir.'/public', $uploadsDir.'/protected', - '/app/storage', - '/app/storage/logs', - '/app/storage/cache', - '/app/storage/twig', - '/app/storage/meta', - '/app/storage/combiner', + '/storage', + '/storage/logs', + '/storage/framework', + '/storage/cms', + '/storage/cms/cache', + '/storage/cms/twig', + '/storage/cms/combiner', ]; $requiredExtensions = [ 'GD' => extension_loaded('gd'), diff --git a/modules/cms/classes/CodeParser.php b/modules/cms/classes/CodeParser.php index fed182d7e..a566d4972 100644 --- a/modules/cms/classes/CodeParser.php +++ b/modules/cms/classes/CodeParser.php @@ -174,7 +174,7 @@ class CodeParser protected function getFilePath() { $hash = abs(crc32($this->filePath)); - $result = storage_path().'/cache/'; + $result = storage_path().'/cms/cache/'; $result .= substr($hash, 0, 2).'/'; $result .= substr($hash, 2, 2).'/'; $result .= basename($this->filePath).'.php'; diff --git a/modules/cms/classes/Controller.php b/modules/cms/classes/Controller.php index 8c5d9d752..ab6befb55 100644 --- a/modules/cms/classes/Controller.php +++ b/modules/cms/classes/Controller.php @@ -361,7 +361,7 @@ class Controller 'debug' => $isDebugMode, ]; if (!Config::get('cms.twigNoCache')) { - $options['cache'] = storage_path().'/twig'; + $options['cache'] = storage_path().'/cms/twig'; } $this->twig = new Twig_Environment($this->loader, $options); diff --git a/modules/system/ServiceProvider.php b/modules/system/ServiceProvider.php index c4d6f920e..39c6d5b9d 100644 --- a/modules/system/ServiceProvider.php +++ b/modules/system/ServiceProvider.php @@ -38,11 +38,6 @@ class ServiceProvider extends ModuleServiceProvider */ parent::register('system'); - /* - * Register core providers - */ - // App::register('October\Rain\Translation\TranslationServiceProvider'); - /* * Define path constants */ @@ -121,7 +116,7 @@ class ServiceProvider extends ModuleServiceProvider /* * Register basic Twig */ - App::bindShared('twig', function ($app) { + App::singleton('twig', function ($app) { $twig = new Twig_Environment(new TwigLoader(), ['auto_reload' => true]); $twig->addExtension(new TwigExtension); return $twig; @@ -137,7 +132,7 @@ class ServiceProvider extends ModuleServiceProvider /* * Register Twig that will parse strings */ - App::bindShared('twig.string', function ($app) { + App::singleton('twig.string', function ($app) { $twig = $app['twig']; $twig->setLoader(new Twig_Loader_String); 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 */ @@ -332,13 +334,6 @@ class ServiceProvider extends ModuleServiceProvider $this->registerConsoleCommand('plugin.remove', 'System\Console\PluginRemove'); $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 */ diff --git a/modules/system/classes/CombineAssets.php b/modules/system/classes/CombineAssets.php index 6259cbc6f..ad50e8c75 100644 --- a/modules/system/classes/CombineAssets.php +++ b/modules/system/classes/CombineAssets.php @@ -171,7 +171,7 @@ class CombineAssets } $this->path = $cacheInfo['path']; - $this->storagePath = storage_path().'/combiner/cms'; + $this->storagePath = storage_path().'/cms/combiner'; $combiner = $this->prepareCombiner($cacheInfo['files']); $contents = $combiner->dump(); @@ -278,7 +278,7 @@ class CombineAssets } $this->path = public_path().$path; - $this->storagePath = storage_path().'/combiner/cms'; + $this->storagePath = storage_path().'/cms/combiner'; list($assets, $extension) = $this->prepareAssets($assets); diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index 491822060..28b2f88ab 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -49,7 +49,7 @@ class PluginManager /** * @var string Path to the disarm file. */ - protected $metaPath; + protected $metaFile; /** * @var array Collection of disabled plugins @@ -67,7 +67,7 @@ class PluginManager protected function init() { $this->app = App::make('app'); - $this->metaPath = Config::get('app.manifest'); + $this->metaFile = storage_path() . '/cms/disabled.json'; $this->loadDisabled(); $this->loadPlugins(); $this->loadDependencies(); @@ -369,7 +369,7 @@ class PluginManager public function clearDisabledCache() { - File::delete($this->metaPath.'/disabled.json'); + File::delete($this->metaFile); $this->disabledPlugins = []; } @@ -378,7 +378,7 @@ class PluginManager */ protected function loadDisabled() { - $path = $this->metaPath.'/disabled.json'; + $path = $this->metaFile; if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) { foreach ($configDisabled as $disabled) { @@ -413,7 +413,7 @@ class PluginManager */ protected function writeDisabled() { - $path = $this->metaPath.'/disabled.json'; + $path = $this->metaFile; File::put($path, json_encode($this->disabledPlugins)); } diff --git a/modules/system/console/CacheClear.php b/modules/system/console/CacheClear.php index 9baec17b2..e0c77d830 100644 --- a/modules/system/console/CacheClear.php +++ b/modules/system/console/CacheClear.php @@ -4,14 +4,39 @@ use App; use Config; use Illuminate\Cache\Console\ClearCommand; use Symfony\Component\Console\Output\NullOutput; +use Illuminate\Cache\CacheManager; +use Illuminate\Filesystem\Filesystem; 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. */ public function fire() { + $storagePath = $this->laravel->storagePath(); + /* * Allow this command to be executed internally */ @@ -22,16 +47,24 @@ class CacheClear extends ClearCommand /* * Combiner */ - foreach ($this->files->directories(storage_path().'/combiner') as $directory) { + foreach ($this->files->directories($storagePath.'/cms/combiner') as $directory) { $this->files->deleteDirectory($directory); } $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 */ 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->info('Twig cache cleared!'); @@ -40,7 +73,7 @@ class CacheClear extends ClearCommand /* * Meta */ - $this->files->delete($this->laravel['config']['app.manifest'].'/disabled.json'); + $this->files->delete($storagePath.'/cms/disabled.json'); parent::fire(); } diff --git a/storage/cms/.gitignore b/storage/cms/.gitignore new file mode 100644 index 000000000..1670e9066 --- /dev/null +++ b/storage/cms/.gitignore @@ -0,0 +1,6 @@ +config.php +routes.php +compiled.php +services.json +events.scanned.php +routes.scanned.php diff --git a/storage/combiner/.gitignore b/storage/cms/cache/.gitignore similarity index 100% rename from storage/combiner/.gitignore rename to storage/cms/cache/.gitignore diff --git a/storage/twig/.gitignore b/storage/cms/combiner/.gitignore similarity index 100% rename from storage/twig/.gitignore rename to storage/cms/combiner/.gitignore diff --git a/storage/views/.gitignore b/storage/cms/twig/.gitignore similarity index 100% rename from storage/views/.gitignore rename to storage/cms/twig/.gitignore