File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of php-cache\adapter-bundle package.
5+ *
6+ * (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
7+ *
8+ * This source file is subject to the MIT license that is bundled
9+ * with this source code in the file LICENSE.
10+ */
11+
12+ namespace Cache \AdapterBundle \Factory ;
13+
14+ use Cache \Adapter \Doctrine \DoctrineCachePool ;
15+ use Doctrine \Common \Cache \FilesystemCache ;
16+ use Symfony \Component \OptionsResolver \OptionsResolver ;
17+
18+ /**
19+ * @author Tobias Nyholm <tobias.nyholm@gmail.com>
20+ */
21+ class DoctrineFilesystemFactory extends AbstractDoctrineAdapterFactory
22+ {
23+ /**
24+ * {@inheritdoc}
25+ */
26+ public function getAdapter (array $ config )
27+ {
28+ $ client = new FilesystemCache ($ config ['directory ' ], $ config ['extension ' ], $ config ['umask ' ]);
29+
30+ return new DoctrineCachePool ($ client );
31+ }
32+
33+ /**
34+ * {@inheritdoc}
35+ */
36+ protected static function configureOptionResolver (OptionsResolver $ resolver )
37+ {
38+ $ resolver ->setDefaults ([
39+ 'extension ' => FilesystemCache::EXTENSION ,
40+ 'umask ' => '0002 ' ,
41+ ]);
42+
43+ $ resolver ->setRequired (['directory ' ]);
44+
45+ $ resolver ->setAllowedTypes ('directory ' , ['string ' ]);
46+ $ resolver ->setAllowedTypes ('extension ' , ['string ' ]);
47+ $ resolver ->setAllowedTypes ('umask ' , ['string ' , 'int ' ]);
48+ }
49+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ services:
1818
1919 cache.factory.doctrine_couchbase :
2020 class : Cache\AdapterBundle\Factory\DoctrineCouchbaseFactory
21+ cache.factory.doctrine_filesystem :
22+ class : Cache\AdapterBundle\Factory\DoctrineFilesystemFactory
2123 cache.factory.doctrine_memcached :
2224 class : Cache\AdapterBundle\Factory\DoctrineMemcachedFactory
2325 cache.factory.doctrine_memcache :
You can’t perform that action at this time.
0 commit comments