ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
PropertyList.php
Go to the documentation of this file.
1 <?php
2 
7 {
12  protected $data = array();
13 
18  protected $parent;
19 
24  protected $cache;
25 
29  public function __construct($parent = null)
30  {
31  $this->parent = $parent;
32  }
33 
39  public function get($name)
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  }
50 
56  public function set($name, $value)
57  {
58  $this->data[$name] = $value;
59  }
60 
66  public function has($name)
67  {
68  return array_key_exists($name, $this->data);
69  }
70 
76  public function reset($name = null)
77  {
78  if ($name == null) {
79  $this->data = array();
80  } else {
81  unset($this->data[$name]);
82  }
83  }
84 
91  public function squash($force = false)
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  }
102 
107  public function getParent()
108  {
109  return $this->parent;
110  }
111 
116  public function setParent($plist)
117  {
118  $this->parent = $plist;
119  }
120 }
121 
122 // vim: et sw=4 sts=4
Add some data
getParent()
Returns the parent plist.
Generic property list implementation.
Definition: PropertyList.php:6
setParent($plist)
Sets the parent plist.
Create styles array
The data for the language used.
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
squash($force=false)
Squashes this property list and all of its property lists into a single array, and returns the array...
reset($name=null)
Resets a value to the value of it&#39;s parent, usually the default.
$data
Internal data-structure for properties.