HTMLPurifier/PropertyList.php Quellcode

PropertyList.php
gehe zur Dokumentation dieser Datei
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




Korrekturen, Hinweise und Ergänzungen

Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.