Skip to content

Commit b2708fc

Browse files
committed
Merge pull request #12 from silentworks/feature/remove-pimple-glue
Removed dependency on Pimple's ServiceProviderInterface and register
2 parents 29d9c10 + bd41d47 commit b2708fc

2 files changed

Lines changed: 5 additions & 15 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ $app->add(new \Slim\HttpCache\Cache('public', 86400));
2626
$container = $app->getContainer();
2727

2828
// Register service provider
29-
$container->register(new \Slim\HttpCache\CacheProvider);
29+
$container['cache'] = function () {
30+
return new \Slim\HttpCache\CacheProvider();
31+
};
3032

3133
// Example route with ETag header
3234
$app->get('/foo', function ($req, $res, $args) {
33-
$resWithEtag = $this['cache']->withEtag($res, 'abc');
35+
$resWithEtag = $this->cache->withEtag($res, 'abc');
3436

3537
return $resWithEtag;
3638
});

src/CacheProvider.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,10 @@
22
namespace Slim\HttpCache;
33

44
use InvalidArgumentException;
5-
use Pimple\Container;
6-
use Pimple\ServiceProviderInterface;
75
use Psr\Http\Message\ResponseInterface;
86

9-
class CacheProvider implements ServiceProviderInterface
7+
class CacheProvider
108
{
11-
/**
12-
* Register this cache provider with a Pimple container
13-
*
14-
* @param Container $container
15-
*/
16-
public function register(Container $container)
17-
{
18-
$container['cache'] = $this;
19-
}
20-
219
/**
2210
* Enable client-side HTTP caching
2311
*

0 commit comments

Comments
 (0)