From b7dae92acbd63cf337479f622d79d9fc8206fbab Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 3 Apr 2016 22:21:41 +0900 Subject: [PATCH] We don't need to make the cache adapter configurable like this --- .../core/src/Foundation/AbstractServer.php | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/framework/core/src/Foundation/AbstractServer.php b/framework/core/src/Foundation/AbstractServer.php index 9feae039d..7bcd7882d 100644 --- a/framework/core/src/Foundation/AbstractServer.php +++ b/framework/core/src/Foundation/AbstractServer.php @@ -86,11 +86,12 @@ abstract class AbstractServer $this->registerLogger($app); + $this->registerCache($app); + $app->register('Flarum\Database\DatabaseServiceProvider'); $app->register('Flarum\Settings\SettingsServiceProvider'); $app->register('Flarum\Locale\LocaleServiceProvider'); $app->register('Illuminate\Bus\BusServiceProvider'); - $app->register('Illuminate\Cache\CacheServiceProvider'); $app->register('Illuminate\Filesystem\FilesystemServiceProvider'); $app->register('Illuminate\Hashing\HashServiceProvider'); $app->register('Illuminate\Mail\MailServiceProvider'); @@ -135,16 +136,6 @@ abstract class AbstractServer 'mail' => [ 'driver' => 'mail', ], - 'cache' => [ - 'default' => 'file', - 'stores' => [ - 'file' => [ - 'driver' => 'file', - 'path' => $app->storagePath().'/cache', - ], - ], - 'prefix' => 'flarum', - ], 'filesystems' => [ 'default' => 'local', 'cloud' => 's3', @@ -174,4 +165,24 @@ abstract class AbstractServer $app->instance('log', $logger); $app->alias('log', 'Psr\Log\LoggerInterface'); } + + /** + * @param Application $app + */ + protected function registerCache(Application $app) + { + $app->singleton('cache.store', function ($app) { + return new \Illuminate\Cache\Repository($app->make('cache.filestore')); + }); + + $app->singleton('cache.filestore', function ($app) { + return new \Illuminate\Cache\FileStore( + new \Illuminate\Filesystem\Filesystem(), + $app->storagePath().'/cache' + ); + }); + + $app->alias('cache.filestore', 'Illuminate\Contracts\Cache\Store'); + $app->alias('cache.store', 'Illuminate\Contracts\Cache\Repository'); + } }