2015-02-11 20:39:25 +11:00
|
|
|
<?php namespace System\Helpers;
|
|
|
|
|
2015-10-09 05:31:50 +11:00
|
|
|
use App;
|
2015-02-11 20:39:25 +11:00
|
|
|
use File;
|
2016-04-16 08:10:14 +10:00
|
|
|
use Cache as CacheFacade;
|
2015-02-11 20:39:25 +11:00
|
|
|
use Config;
|
|
|
|
|
|
|
|
class Cache
|
|
|
|
{
|
|
|
|
use \October\Rain\Support\Traits\Singleton;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*/
|
|
|
|
public static function clear()
|
2016-04-16 08:10:14 +10:00
|
|
|
{
|
|
|
|
CacheFacade::flush();
|
|
|
|
self::clearInternal();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function clearInternal()
|
2015-02-11 20:39:25 +11:00
|
|
|
{
|
|
|
|
$instance = self::instance();
|
|
|
|
$instance->clearCombiner();
|
|
|
|
$instance->clearCache();
|
|
|
|
|
|
|
|
if (!Config::get('cms.twigNoCache')) {
|
|
|
|
$instance->clearTwig();
|
|
|
|
}
|
|
|
|
|
|
|
|
$instance->clearMeta();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Combiner
|
|
|
|
*/
|
|
|
|
public function clearCombiner()
|
|
|
|
{
|
|
|
|
foreach (File::directories(storage_path().'/cms/combiner') as $directory) {
|
|
|
|
File::deleteDirectory($directory);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-02-11 20:46:06 +11:00
|
|
|
* Cache
|
2015-02-11 20:39:25 +11:00
|
|
|
*/
|
|
|
|
public function clearCache()
|
|
|
|
{
|
|
|
|
foreach (File::directories(storage_path().'/cms/cache') as $directory) {
|
|
|
|
File::deleteDirectory($directory);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Twig
|
|
|
|
*/
|
|
|
|
public function clearTwig()
|
|
|
|
{
|
|
|
|
foreach (File::directories(storage_path().'/cms/twig') as $directory) {
|
|
|
|
File::deleteDirectory($directory);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Meta
|
|
|
|
*/
|
|
|
|
public function clearMeta()
|
|
|
|
{
|
|
|
|
File::delete(storage_path().'/cms/disabled.json');
|
2015-10-09 05:31:50 +11:00
|
|
|
File::delete(App::getCachedCompilePath());
|
|
|
|
File::delete(App::getCachedServicesPath());
|
2015-02-11 20:39:25 +11:00
|
|
|
}
|
|
|
|
}
|