ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_DefinitionCacheFactory Class Reference

Responsible for creating definition caches. More...

+ Collaboration diagram for HTMLPurifier_DefinitionCacheFactory:

Public Member Functions

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

Static Public Member Functions

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

Protected Attributes

 $caches = array('Serializer' => array())
 array
 $implementations = array()
 array
 $decorators = array()
 HTMLPurifier_DefinitionCache_Decorator[]

Detailed Description

Responsible for creating definition caches.

Definition at line 6 of file DefinitionCacheFactory.php.

Member Function Documentation

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.

Referenced by setup().

{
if (is_string($decorator)) {
$class = "HTMLPurifier_DefinitionCache_Decorator_$decorator";
$decorator = new $class;
}
$this->decorators[$decorator->name] = $decorator;
}

+ Here is the caller graph for this function:

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.

{
$method = $config->get('Cache.DefinitionImpl');
if ($method === null) {
}
if (!empty($this->caches[$method][$type])) {
return $this->caches[$method][$type];
}
if (isset($this->implementations[$method]) &&
class_exists($class = $this->implementations[$method], false)) {
$cache = new $class($type);
} else {
if ($method != 'Serializer') {
trigger_error("Unrecognized DefinitionCache $method, using Serializer instead", E_USER_WARNING);
}
}
foreach ($this->decorators as $decorator) {
$new_cache = $decorator->decorate($cache);
// prevent infinite recursion in PHP 4
unset($cache);
$cache = $new_cache;
}
$this->caches[$method][$type] = $cache;
return $this->caches[$method][$type];
}
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.

Referenced by HTMLPurifier_Config\getDefinition().

{
static $instance;
if ($prototype !== null) {
$instance = $prototype;
} elseif ($instance === null || $prototype === true) {
$instance->setup();
}
return $instance;
}

+ Here is the caller graph for this function:

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.

{
$this->implementations[$short] = $long;
}
HTMLPurifier_DefinitionCacheFactory::setup ( )

Initialize default decorators.

Definition at line 26 of file DefinitionCacheFactory.php.

References addDecorator().

{
$this->addDecorator('Cleanup');
}

+ Here is the call graph for this function:

Field Documentation

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

array

Definition at line 11 of file DefinitionCacheFactory.php.

HTMLPurifier_DefinitionCacheFactory::$decorators = array()
protected
HTMLPurifier_DefinitionCacheFactory::$implementations = array()
protected

array

Definition at line 16 of file DefinitionCacheFactory.php.


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