From 9e14ac42794d038f1d1c64ab305b4434e8e6dfd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 29 Nov 2019 12:11:10 +0100 Subject: [PATCH] Making code compatible with Symfony 5 cache --- composer.json | 3 ++- src/Providers/GraphQLiteServiceProvider.php | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index fea85c8..8c08611 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "illuminate/support": "^5.7|^6.0", "illuminate/cache": "^5.7|^6.0", "symfony/psr-http-message-bridge": "^1", - "zendframework/zend-diactoros": "^1.8.6" + "zendframework/zend-diactoros": "^1.8.6", + "symfony/cache": "^4.3 || ^5" }, "require-dev": { "orchestra/testbench": "^3.7.7 || ^4", diff --git a/src/Providers/GraphQLiteServiceProvider.php b/src/Providers/GraphQLiteServiceProvider.php index 8cf8f2e..605b94d 100644 --- a/src/Providers/GraphQLiteServiceProvider.php +++ b/src/Providers/GraphQLiteServiceProvider.php @@ -4,6 +4,9 @@ use Illuminate\Contracts\Auth\Access\Gate; use Illuminate\Contracts\Auth\Factory as AuthFactory; +use Symfony\Component\Cache\Adapter\ApcuAdapter; +use Symfony\Component\Cache\Adapter\PhpFilesAdapter; +use Symfony\Component\Cache\Psr16Cache; use TheCodingMachine\GraphQLite\Context\Context; use TheCodingMachine\GraphQLite\Exceptions\WebonyxErrorHandler; use TheCodingMachine\GraphQLite\Laravel\Mappers\Parameters\ValidateFieldMiddleware; @@ -79,9 +82,9 @@ public function register() $this->app->singleton('graphqliteCache', static function () { if (extension_loaded('apcu') && ini_get('apc.enabled')) { - return new \Symfony\Component\Cache\Simple\ApcuCache(); + return new Psr16Cache(new ApcuAdapter()); } else { - return new \Symfony\Component\Cache\Simple\PhpFilesCache(); + return new Psr16Cache(new PhpFilesAdapter()); } });