Skip to content

Commit

Permalink
Merge pull request #5 from Rarst/silex-v2
Browse files Browse the repository at this point in the history
Updated for Silex v2
  • Loading branch information
CHH authored Nov 21, 2016
2 parents 6ad4ffb + 4174bce commit d8d2a92
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": ">=5.3.3",
"silex/silex": "~1.0",
"silex/silex": "^2.0",
"doctrine/cache": "~1.0"
},
"minimum-stability": "dev",
Expand Down
22 changes: 9 additions & 13 deletions lib/CHH/Silex/CacheServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace CHH\Silex;

use Silex\Application;
use Silex\ServiceProviderInterface;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Doctrine\Common\Cache\Cache;
use CHH\Silex\CacheServiceProvider\CacheNamespace;

class CacheServiceProvider implements ServiceProviderInterface
{
function register(Application $app)
function register(Container $app)
{
$app['cache.factory'] = $app->protect(function($options) {
return function() use ($options) {
Expand Down Expand Up @@ -89,23 +89,19 @@ function register(Application $app)
};
});

$app['cache'] = $app->share(function($app) {
$app['cache'] = function($app) {
$factory = $app['cache.factory']($app['cache.options']['default']);
return $factory();
});
};

$app['caches'] = $app->share(function($app) {
$caches = new \Pimple;
$app['caches'] = function($app) {
$caches = new Container;

foreach ($app['cache.options'] as $cache => $options) {
$caches[$cache] = $app->share($app['cache.factory']($options));
$caches[$cache] = $app['cache.factory']($options);
}

return $caches;
});
}

function boot(Application $app)
{
};
}
}

0 comments on commit d8d2a92

Please sign in to comment.