Skip to content

Commit 9858ab0

Browse files
author
Richard Hoogstad
committed
added filesystem as cache
1 parent d95ccd7 commit 9858ab0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Dflydev/Pimple/Provider/DoctrineOrm/DoctrineOrmServiceProvider.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ public function register(\Pimple $app)
137137
case 'annotation':
138138
$useSimpleAnnotationReader =
139139
isset($entity['use_simple_annotation_reader'])
140-
? $entity['use_simple_annotation_reader']
141-
: true;
140+
? $entity['use_simple_annotation_reader']
141+
: true;
142142
$driver = $config->newDefaultAnnotationDriver((array) $entity['path'], $useSimpleAnnotationReader);
143143
$chain->addDriver($driver, $entity['namespace']);
144144
break;
@@ -254,6 +254,13 @@ public function register(\Pimple $app)
254254
return new XcacheCache;
255255
});
256256

257+
$app['orm.cache.factory.filesystem'] = $app->protect(function() use ($app) {
258+
if (empty($app['orm.cache.path'])) {
259+
throw new \RuntimeException('FilesystemCache not defined');
260+
}
261+
return new FilesystemCache($app['orm.cache.path']);
262+
});
263+
257264
$app['orm.cache.factory'] = $app->protect(function($driver, $cacheOptions) use ($app) {
258265
switch ($driver) {
259266
case 'array':
@@ -266,6 +273,8 @@ public function register(\Pimple $app)
266273
return $app['orm.cache.factory.memcache']($cacheOptions);
267274
case 'memcached':
268275
return $app['orm.cache.factory.memcached']($cacheOptions);
276+
case 'filesystem':
277+
return $app['orm.cache.factory.filesystem']();
269278
default:
270279
throw new \RuntimeException("Unsupported cache type '$driver' specified");
271280
}

0 commit comments

Comments
 (0)