Registry object that contains information about the current context.
More...
Public Member Functions |
| register ($name, &$ref) |
| Registers a variable into the context.
|
& | get ($name, $ignore_error=false) |
| Retrieves a variable reference from the context.
|
| destroy ($name) |
| Destroys a variable in the context.
|
| exists ($name) |
| Checks whether or not the variable exists.
|
| loadArray ($context_array) |
| Loads a series of variables from an associative array.
|
Private Attributes |
| $_storage = array() |
| Private array that stores the references.
|
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
HTMLPurifier_Context::destroy |
( |
|
$name | ) |
|
Destroys a variable in the context.
- Parameters
-
Definition at line 61 of file Context.php.
{
if (!array_key_exists($name, $this->_storage)) {
trigger_error(
"Attempted to destroy non-existent variable $name",
E_USER_ERROR
);
return;
}
unset($this->_storage[$name]);
}
HTMLPurifier_Context::exists |
( |
|
$name | ) |
|
Checks whether or not the variable exists.
- Parameters
-
- Returns
- bool
Definition at line 78 of file Context.php.
{
return array_key_exists($name, $this->_storage);
}
& HTMLPurifier_Context::get |
( |
|
$name, |
|
|
|
$ignore_error = false |
|
) |
| |
Retrieves a variable reference from the context.
- Parameters
-
string | $name | String name |
bool | $ignore_error | Boolean whether or not to ignore error |
- Returns
- mixed
Definition at line 42 of file Context.php.
{
if (!array_key_exists($name, $this->_storage)) {
if (!$ignore_error) {
trigger_error(
"Attempted to retrieve non-existent variable $name",
E_USER_ERROR
);
}
$var = null;
return $var;
}
return $this->_storage[$name];
}
HTMLPurifier_Context::loadArray |
( |
|
$context_array | ) |
|
Loads a series of variables from an associative array.
- Parameters
-
array | $context_array | Assoc array of variables to load |
Definition at line 87 of file Context.php.
{
foreach ($context_array as $key => $discard) {
$this->register($key, $context_array[$key]);
}
}
HTMLPurifier_Context::register |
( |
|
$name, |
|
|
& |
$ref |
|
) |
| |
Registers a variable into the context.
- Parameters
-
string | $name | String name |
mixed | $ref | Reference to variable to be registered |
Definition at line 24 of file Context.php.
{
if (array_key_exists($name, $this->_storage)) {
trigger_error(
"Name $name produces collision, cannot re-register",
E_USER_ERROR
);
return;
}
$this->_storage[$name] =& $ref;
}
Field Documentation
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:
- Services/Html/HtmlPurifier/library/HTMLPurifier/Context.php