diff options
author | Igor Wiedler <igor@wiedler.ch> | 2010-11-03 18:35:31 +0100 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2011-01-09 23:49:35 +0100 |
commit | 9329b16ab13f3a4caf107df358c3c58bda2dcd8a (patch) | |
tree | 0b5faa7111c792565062c93b1c1a44eda50d4664 /phpBB/includes/cache/factory.php | |
parent | 36e95f939db9b88b8519d956120d161102184ccb (diff) | |
download | forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.tar forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.tar.gz forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.tar.bz2 forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.tar.xz forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.zip |
[task/acm-refactor] Refactor the ACM classes to have a common interface.
They are now refered to as cache drivers rather than ACM classes. The
additional utility functions from the original cache class have been
moved to the cache_service. The class loader is now instantiated without
a cache instance and passed one as soon as it is constructed to allow
autoloading the cache classes.
PHPBB3-9983
Diffstat (limited to 'phpBB/includes/cache/factory.php')
-rw-r--r-- | phpBB/includes/cache/factory.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/phpBB/includes/cache/factory.php b/phpBB/includes/cache/factory.php new file mode 100644 index 0000000000..cc88780bf2 --- /dev/null +++ b/phpBB/includes/cache/factory.php @@ -0,0 +1,52 @@ +<?php +/** +* +* @package acm +* @version $Id$ +* @copyright (c) 2010 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* @package acm +*/ +class phpbb_cache_factory +{ + private $acm_type; + + public function __construct($acm_type) + { + $this->acm_type = $acm_type; + } + + public function get_acm() + { + $class_name = 'phpbb_cache_driver_' . $this->acm_type; + return new $class_name(); + } + + public function get_service() + { + $acm = $this->get_acm(); + $service = new phpbb_cache_service($acm); + return $service; + } + + /** + * for convenience to allow: + * $cache = phpbb_cache_factory::create('file')->get_service(); + */ + public static function create($acm_type) + { + return new self($acm_type); + } +} |