From 266d1fc0a327de96dc76a6210f28e099c4d06e8e Mon Sep 17 00:00:00 2001 From: Yury Buldakov Date: Sat, 29 Apr 2017 21:23:25 +0300 Subject: [PATCH] Small improvement to make api usable by the bundle This should fix php-tmdb/symfony#17 --- README.md | 3 +-- examples/caching.php | 4 +--- lib/Tmdb/Client.php | 5 +---- lib/Tmdb/HttpClient/HttpClient.php | 4 +++- test/Tmdb/Tests/TestCase.php | 3 +-- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8505a23a..e0990e68 100644 --- a/README.md +++ b/README.md @@ -123,11 +123,10 @@ $client = new \Tmdb\Client($token, [ ```php use Doctrine\Common\Cache\ArrayCache; -use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage; $client = new \Tmdb\Client($token, [ 'cache' => [ - 'handler' => new DoctrineCacheStorage(new ArrayCache()) + 'handler' => new ArrayCache() ] ] ); diff --git a/examples/caching.php b/examples/caching.php index 5ff2caa6..0d964be4 100644 --- a/examples/caching.php +++ b/examples/caching.php @@ -25,9 +25,7 @@ $client = new \Tmdb\Client($token, [ 'cache' => [ 'enabled' => true, - 'handler' => new \Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage( - new Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'my-cache-path') - ) + 'handler' => new Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'my-cache-path') ] ]); diff --git a/lib/Tmdb/Client.php b/lib/Tmdb/Client.php index 2411b4db..4accf3cf 100644 --- a/lib/Tmdb/Client.php +++ b/lib/Tmdb/Client.php @@ -13,7 +13,6 @@ namespace Tmdb; use Doctrine\Common\Cache\FilesystemCache; -use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage; use Monolog\Handler\StreamHandler; use Psr\Log\LogLevel; use Symfony\Component\EventDispatcher\EventDispatcher; @@ -272,9 +271,7 @@ protected function configureCacheOptions(array $options = []) $options = $resolver->resolve(array_key_exists('cache', $options) ? $options['cache'] : []); if ($options['enabled'] && !$options['handler']) { - $options['handler'] = new DoctrineCacheStorage( - new FilesystemCache($options['path']) - ); + $options['handler'] = new FilesystemCache($options['path']); } return $options; diff --git a/lib/Tmdb/HttpClient/HttpClient.php b/lib/Tmdb/HttpClient/HttpClient.php index 91469190..677c933c 100644 --- a/lib/Tmdb/HttpClient/HttpClient.php +++ b/lib/Tmdb/HttpClient/HttpClient.php @@ -450,7 +450,9 @@ public function setDefaultCaching(array $parameters) $this->adapter->getClient()->getConfig('handler')->push( new CacheMiddleware( new PrivateCacheStrategy( - $parameters['handler'] + new DoctrineCacheStorage( + $parameters['handler'] + ) ) ), 'tmdb-cache' diff --git a/test/Tmdb/Tests/TestCase.php b/test/Tmdb/Tests/TestCase.php index b3e03001..4b338c8f 100644 --- a/test/Tmdb/Tests/TestCase.php +++ b/test/Tmdb/Tests/TestCase.php @@ -13,7 +13,6 @@ namespace Tmdb\Tests; use Doctrine\Common\Cache\FilesystemCache; -use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage; use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\ApiToken; use Tmdb\Client; @@ -174,7 +173,7 @@ protected function getRequest($path, $parameters = [], $method = 'GET', $headers 'secure' => true, 'cache' => [ 'enabled' => true, - 'handler' => new DoctrineCacheStorage(new FilesystemCache(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-tmdb-api')), + 'handler' => new FilesystemCache(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-tmdb-api'), 'path' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-tmdb-api', 'subscriber' => null ],