11 protected $caches = array(
'Serializer' => array());
36 public static function instance($prototype = null)
39 if ($prototype !== null) {
40 $instance = $prototype;
41 } elseif ($instance === null || $prototype ===
true) {
53 public function register($short, $long)
55 $this->implementations[$short] = $long;
64 public function create($type, $config)
66 $method = $config->get(
'Cache.DefinitionImpl');
67 if ($method === null) {
70 if (!empty($this->caches[$method][$type])) {
71 return $this->caches[$method][$type];
73 if (isset($this->implementations[$method]) &&
74 class_exists($class = $this->implementations[$method],
false)) {
75 $cache =
new $class($type);
77 if ($method !=
'Serializer') {
78 trigger_error(
"Unrecognized DefinitionCache $method, using Serializer instead", E_USER_WARNING);
82 foreach ($this->decorators as $decorator) {
83 $new_cache = $decorator->decorate($cache);
88 $this->caches[$method][$type] = $cache;
89 return $this->caches[$method][$type];
98 if (is_string($decorator)) {
99 $class =
"HTMLPurifier_DefinitionCache_Decorator_$decorator";
100 $decorator =
new $class;
102 $this->decorators[$decorator->name] = $decorator;