ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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())
 
 $implementations = array()
 
 $decorators = array()
 

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

Definition at line 81 of file DefinitionCacheFactory.php.

Referenced by setup().

81  {
82  if (is_string($decorator)) {
83  $class = "HTMLPurifier_DefinitionCache_Decorator_$decorator";
84  $decorator = new $class;
85  }
86  $this->decorators[$decorator->name] = $decorator;
87  }
+ 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
$nameName of definitions handled by cache
$configInstance of HTMLPurifier_Config

Definition at line 48 of file DefinitionCacheFactory.php.

48  {
49  $method = $config->get('Cache.DefinitionImpl');
50  if ($method === null) {
51  return new HTMLPurifier_DefinitionCache_Null($type);
52  }
53  if (!empty($this->caches[$method][$type])) {
54  return $this->caches[$method][$type];
55  }
56  if (
57  isset($this->implementations[$method]) &&
58  class_exists($class = $this->implementations[$method], false)
59  ) {
60  $cache = new $class($type);
61  } else {
62  if ($method != 'Serializer') {
63  trigger_error("Unrecognized DefinitionCache $method, using Serializer instead", E_USER_WARNING);
64  }
65  $cache = new HTMLPurifier_DefinitionCache_Serializer($type);
66  }
67  foreach ($this->decorators as $decorator) {
68  $new_cache = $decorator->decorate($cache);
69  // prevent infinite recursion in PHP 4
70  unset($cache);
71  $cache = $new_cache;
72  }
73  $this->caches[$method][$type] = $cache;
74  return $this->caches[$method][$type];
75  }
Null cache object to use when no caching is on.
Definition: Null.php:6

◆ instance()

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

Retrieves an instance of global definition cache factory.

Definition at line 23 of file DefinitionCacheFactory.php.

Referenced by HTMLPurifier_Config\getDefinition().

23  {
24  static $instance;
25  if ($prototype !== null) {
26  $instance = $prototype;
27  } elseif ($instance === null || $prototype === true) {
28  $instance = new HTMLPurifier_DefinitionCacheFactory();
29  $instance->setup();
30  }
31  return $instance;
32  }
Responsible for creating definition caches.
+ Here is the caller graph for this function:

◆ register()

HTMLPurifier_DefinitionCacheFactory::register (   $short,
  $long 
)

Registers a new definition cache object.

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

Definition at line 39 of file DefinitionCacheFactory.php.

39  {
40  $this->implementations[$short] = $long;
41  }

◆ setup()

HTMLPurifier_DefinitionCacheFactory::setup ( )

Initialize default decorators.

Definition at line 16 of file DefinitionCacheFactory.php.

References addDecorator().

16  {
17  $this->addDecorator('Cleanup');
18  }
addDecorator($decorator)
Registers a decorator to add to all new cache objects.
+ Here is the call graph for this function:

Field Documentation

◆ $caches

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

Definition at line 9 of file DefinitionCacheFactory.php.

◆ $decorators

HTMLPurifier_DefinitionCacheFactory::$decorators = array()
protected

Definition at line 11 of file DefinitionCacheFactory.php.

◆ $implementations

HTMLPurifier_DefinitionCacheFactory::$implementations = array()
protected

Definition at line 10 of file DefinitionCacheFactory.php.


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