ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
HTMLPurifier_DefinitionCacheFactory Class Reference

Responsible for creating definition caches. More...

+ Collaboration diagram for HTMLPurifier_DefinitionCacheFactory:

Public Member Functions

 setup ()
 Initialize default decorators. More...
 
 register ($short, $long)
 Registers a new definition cache object. More...
 
 create ($type, $config)
 Factory method that creates a cache object based on configuration. More...
 
 addDecorator ($decorator)
 Registers a decorator to add to all new cache objects. More...
 

Static Public Member Functions

static instance ($prototype=null)
 Retrieves an instance of global definition cache factory. More...
 

Protected Attributes

 $caches = array('Serializer' => array())
 @type array More...
 
 $implementations = array()
 @type array More...
 
 $decorators = array()
 @type HTMLPurifier_DefinitionCache_Decorator[] More...
 

Detailed Description

Responsible for creating definition caches.

Definition at line 6 of file DefinitionCacheFactory.php.

Member Function Documentation

◆ addDecorator()

HTMLPurifier_DefinitionCacheFactory::addDecorator (   $decorator)

Registers a decorator to add to all new cache objects.

Parameters
HTMLPurifier_DefinitionCache_Decorator | string$decoratorAn instance or the name of a decorator

Definition at line 96 of file DefinitionCacheFactory.php.

97 {
98 if (is_string($decorator)) {
99 $class = "HTMLPurifier_DefinitionCache_Decorator_$decorator";
100 $decorator = new $class;
101 }
102 $this->decorators[$decorator->name] = $decorator;
103 }

Referenced by setup().

+ Here is the caller graph for this function:

◆ create()

HTMLPurifier_DefinitionCacheFactory::create (   $type,
  $config 
)

Factory method that creates a cache object based on configuration.

Parameters
string$typeName of definitions handled by cache
HTMLPurifier_Config$configConfig instance
Returns
mixed

Definition at line 64 of file DefinitionCacheFactory.php.

65 {
66 $method = $config->get('Cache.DefinitionImpl');
67 if ($method === null) {
68 return new HTMLPurifier_DefinitionCache_Null($type);
69 }
70 if (!empty($this->caches[$method][$type])) {
71 return $this->caches[$method][$type];
72 }
73 if (isset($this->implementations[$method]) &&
74 class_exists($class = $this->implementations[$method], false)) {
75 $cache = new $class($type);
76 } else {
77 if ($method != 'Serializer') {
78 trigger_error("Unrecognized DefinitionCache $method, using Serializer instead", E_USER_WARNING);
79 }
81 }
82 foreach ($this->decorators as $decorator) {
83 $new_cache = $decorator->decorate($cache);
84 // prevent infinite recursion in PHP 4
85 unset($cache);
86 $cache = $new_cache;
87 }
88 $this->caches[$method][$type] = $cache;
89 return $this->caches[$method][$type];
90 }
Null cache object to use when no caching is on.
Definition: Null.php:7

◆ instance()

static HTMLPurifier_DefinitionCacheFactory::instance (   $prototype = null)
static

Retrieves an instance of global definition cache factory.

Parameters
HTMLPurifier_DefinitionCacheFactory$prototype
Returns
HTMLPurifier_DefinitionCacheFactory

Definition at line 36 of file DefinitionCacheFactory.php.

37 {
38 static $instance;
39 if ($prototype !== null) {
40 $instance = $prototype;
41 } elseif ($instance === null || $prototype === true) {
43 $instance->setup();
44 }
45 return $instance;
46 }
Responsible for creating definition caches.

Referenced by HTMLPurifier_Config\getDefinition().

+ Here is the caller graph for this function:

◆ register()

HTMLPurifier_DefinitionCacheFactory::register (   $short,
  $long 
)

Registers a new definition cache object.

Parameters
string$shortShort name of cache object, for reference
string$longFull class name of cache object, for construction

Definition at line 53 of file DefinitionCacheFactory.php.

54 {
55 $this->implementations[$short] = $long;
56 }

◆ setup()

HTMLPurifier_DefinitionCacheFactory::setup ( )

Initialize default decorators.

Definition at line 26 of file DefinitionCacheFactory.php.

27 {
28 $this->addDecorator('Cleanup');
29 }
addDecorator($decorator)
Registers a decorator to add to all new cache objects.

References addDecorator().

+ Here is the call graph for this function:

Field Documentation

◆ $caches

HTMLPurifier_DefinitionCacheFactory::$caches = array('Serializer' => array())
protected

@type array

Definition at line 11 of file DefinitionCacheFactory.php.

◆ $decorators

HTMLPurifier_DefinitionCacheFactory::$decorators = array()
protected

◆ $implementations

HTMLPurifier_DefinitionCacheFactory::$implementations = array()
protected

@type array

Definition at line 16 of file DefinitionCacheFactory.php.


The documentation for this class was generated from the following file: