ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e
HTMLPurifier_Context Class Reference

Registry object that contains information about the current context. More...

+ Collaboration diagram for HTMLPurifier_Context:

Public Member Functions

 register ($name, &$ref)
 Registers a variable into the context. More...
 
get ($name, $ignore_error=false)
 Retrieves a variable reference from the context. More...
 
 destroy ($name)
 Destroys a variable in the context. More...
 
 exists ($name)
 Checks whether or not the variable exists. More...
 
 loadArray ($context_array)
 Loads a series of variables from an associative array. More...
 

Private Attributes

 $_storage = array()
 Private array that stores the references. More...
 

Detailed Description

Registry object that contains information about the current context.

Warning
Is a bit buggy when variables are set to null: it thinks they don't exist! So use false instead, please.
Note
Since the variables Context deals with may not be objects, references are very important here! Do not remove!

Definition at line 10 of file Context.php.

Member Function Documentation

◆ destroy()

HTMLPurifier_Context::destroy (   $name)

Destroys a variable in the context.

Parameters
string$nameString name

Definition at line 61 of file Context.php.

References $name.

62  {
63  if (!array_key_exists($name, $this->_storage)) {
64  trigger_error(
65  "Attempted to destroy non-existent variable $name",
66  E_USER_ERROR
67  );
68  return;
69  }
70  unset($this->_storage[$name]);
71  }

◆ exists()

HTMLPurifier_Context::exists (   $name)

Checks whether or not the variable exists.

Parameters
string$nameString name
Returns
bool

Definition at line 78 of file Context.php.

References $name.

79  {
80  return array_key_exists($name, $this->_storage);
81  }

◆ get()

& HTMLPurifier_Context::get (   $name,
  $ignore_error = false 
)

Retrieves a variable reference from the context.

Parameters
string$nameString name
bool$ignore_errorBoolean whether or not to ignore error
Returns
mixed

Definition at line 42 of file Context.php.

References $name.

43  {
44  if (!array_key_exists($name, $this->_storage)) {
45  if (!$ignore_error) {
46  trigger_error(
47  "Attempted to retrieve non-existent variable $name",
48  E_USER_ERROR
49  );
50  }
51  $var = null; // so we can return by reference
52  return $var;
53  }
54  return $this->_storage[$name];
55  }

◆ loadArray()

HTMLPurifier_Context::loadArray (   $context_array)

Loads a series of variables from an associative array.

Parameters
array$context_arrayAssoc array of variables to load

Definition at line 87 of file Context.php.

References $key.

88  {
89  foreach ($context_array as $key => $discard) {
90  $this->register($key, $context_array[$key]);
91  }
92  }
$key
Definition: croninfo.php:18

◆ register()

HTMLPurifier_Context::register (   $name,
$ref 
)

Registers a variable into the context.

Parameters
string$nameString name
mixed$refReference to variable to be registered

Definition at line 24 of file Context.php.

References $name.

25  {
26  if (array_key_exists($name, $this->_storage)) {
27  trigger_error(
28  "Name $name produces collision, cannot re-register",
29  E_USER_ERROR
30  );
31  return;
32  }
33  $this->_storage[$name] =& $ref;
34  }

Field Documentation

◆ $_storage

HTMLPurifier_Context::$_storage = array()
private

Private array that stores the references.

array

Definition at line 17 of file Context.php.


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