diff options
Diffstat (limited to 'app/ServiceProvider')
-rw-r--r-- | app/ServiceProvider/CacheProvider.php | 41 | ||||
-rw-r--r-- | app/ServiceProvider/ClassProvider.php | 3 |
2 files changed, 41 insertions, 3 deletions
diff --git a/app/ServiceProvider/CacheProvider.php b/app/ServiceProvider/CacheProvider.php new file mode 100644 index 00000000..0d56e601 --- /dev/null +++ b/app/ServiceProvider/CacheProvider.php @@ -0,0 +1,41 @@ +<?php + +namespace Kanboard\ServiceProvider; + +use Kanboard\Core\Cache\FileCache; +use Kanboard\Core\Cache\MemoryCache; +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Cache Provider + * + * @package Kanboard\ServiceProvider + * @author Frederic Guillot + */ +class CacheProvider implements ServiceProviderInterface +{ + /** + * Register providers + * + * @access public + * @param \Pimple\Container $container + * @return \Pimple\Container + */ + public function register(Container $container) + { + $container['memoryCache'] = function() { + return new MemoryCache(); + }; + + if (CACHE_DRIVER === 'file') { + $container['cacheDriver'] = function() { + return new FileCache(); + }; + } else { + $container['cacheDriver'] = $container['memoryCache']; + } + + return $container; + } +} diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php index aab41c74..d837500a 100644 --- a/app/ServiceProvider/ClassProvider.php +++ b/app/ServiceProvider/ClassProvider.php @@ -140,9 +140,6 @@ class ClassProvider implements ServiceProviderInterface 'Response', 'RememberMeCookie', ), - 'Core\Cache' => array( - 'MemoryCache', - ), 'Core\Plugin' => array( 'Hook', ), |