ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
HTMLPurifier_PropertyList Class Reference

Generic property list implementation. More...

+ Collaboration diagram for HTMLPurifier_PropertyList:

Public Member Functions

 __construct ($parent=null)
 
 get ($name)
 Recursively retrieves the value for a key. More...
 
 set ($name, $value)
 Sets the value of a key, for this plist. More...
 
 has ($name)
 Returns true if a given key exists. More...
 
 reset ($name=null)
 Resets a value to the value of it's parent, usually the default. More...
 
 squash ($force=false)
 Squashes this property list and all of its property lists into a single array, and returns the array. More...
 
 getParent ()
 Returns the parent plist. More...
 
 setParent ($plist)
 Sets the parent plist. More...
 

Protected Attributes

 $data = array()
 Internal data-structure for properties. More...
 
 $parent
 Parent plist. More...
 
 $cache
 Cache. More...
 

Detailed Description

Generic property list implementation.

Definition at line 6 of file PropertyList.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_PropertyList::__construct (   $parent = null)
Parameters
HTMLPurifier_PropertyList$parentParent plist

Definition at line 29 of file PropertyList.php.

References $parent.

30  {
31  $this->parent = $parent;
32  }

Member Function Documentation

◆ get()

HTMLPurifier_PropertyList::get (   $name)

Recursively retrieves the value for a key.

Parameters
string$name
Exceptions
HTMLPurifier_Exception

Definition at line 39 of file PropertyList.php.

References has().

40  {
41  if ($this->has($name)) {
42  return $this->data[$name];
43  }
44  // possible performance bottleneck, convert to iterative if necessary
45  if ($this->parent) {
46  return $this->parent->get($name);
47  }
48  throw new HTMLPurifier_Exception("Key '$name' not found");
49  }
has($name)
Returns true if a given key exists.
Global exception class for HTML Purifier; any exceptions we throw are from here.
Definition: Exception.php:7
+ Here is the call graph for this function:

◆ getParent()

HTMLPurifier_PropertyList::getParent ( )

Returns the parent plist.

Returns
HTMLPurifier_PropertyList

Definition at line 107 of file PropertyList.php.

References $parent.

108  {
109  return $this->parent;
110  }

◆ has()

HTMLPurifier_PropertyList::has (   $name)

Returns true if a given key exists.

Parameters
string$name
Returns
bool

Definition at line 66 of file PropertyList.php.

Referenced by get().

67  {
68  return array_key_exists($name, $this->data);
69  }
+ Here is the caller graph for this function:

◆ reset()

HTMLPurifier_PropertyList::reset (   $name = null)

Resets a value to the value of it's parent, usually the default.

If no value is specified, the entire plist is reset.

Parameters
string$name

Definition at line 76 of file PropertyList.php.

77  {
78  if ($name == null) {
79  $this->data = array();
80  } else {
81  unset($this->data[$name]);
82  }
83  }

◆ set()

HTMLPurifier_PropertyList::set (   $name,
  $value 
)

Sets the value of a key, for this plist.

Parameters
string$name
mixed$value

Definition at line 56 of file PropertyList.php.

57  {
58  $this->data[$name] = $value;
59  }

◆ setParent()

HTMLPurifier_PropertyList::setParent (   $plist)

Sets the parent plist.

Parameters
HTMLPurifier_PropertyList$plistParent plist

Definition at line 116 of file PropertyList.php.

117  {
118  $this->parent = $plist;
119  }

◆ squash()

HTMLPurifier_PropertyList::squash (   $force = false)

Squashes this property list and all of its property lists into a single array, and returns the array.

This value is cached by default.

Parameters
bool$forceIf true, ignores the cache and regenerates the array.
Returns
array

Definition at line 91 of file PropertyList.php.

References $cache, and $data.

92  {
93  if ($this->cache !== null && !$force) {
94  return $this->cache;
95  }
96  if ($this->parent) {
97  return $this->cache = array_merge($this->parent->squash($force), $this->data);
98  } else {
99  return $this->cache = $this->data;
100  }
101  }
$data
Internal data-structure for properties.

Field Documentation

◆ $cache

HTMLPurifier_PropertyList::$cache
protected

Cache.

array

Definition at line 24 of file PropertyList.php.

Referenced by squash().

◆ $data

HTMLPurifier_PropertyList::$data = array()
protected

Internal data-structure for properties.

array

Definition at line 12 of file PropertyList.php.

Referenced by squash().

◆ $parent

HTMLPurifier_PropertyList::$parent
protected

Parent plist.

HTMLPurifier_PropertyList

Definition at line 18 of file PropertyList.php.

Referenced by __construct(), and getParent().


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