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;
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;
addDecorator($decorator)
Registers a decorator to add to all new cache objects.
$decorators
HTMLPurifier_DefinitionCache_Decorator[]
setup()
Initialize default decorators.
create($type, $config)
Factory method that creates a cache object based on configuration.
static instance($prototype=null)
Retrieves an instance of global definition cache factory.
Null cache object to use when no caching is on.
Create styles array
The data for the language used.
Responsible for creating definition caches.