1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 06:07:26 +02:00

[3.1.0] Create decorator validator/adapter for Interchange.

- Output flush output

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1587 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-02 04:00:43 +00:00
parent d81bcbd208
commit 0d9c05d13c
7 changed files with 99 additions and 24 deletions

View File

@@ -0,0 +1,45 @@
<?php
/**
* Decorator for interchange that performs validations
*/
class HTMLPurifier_ConfigSchema_InterchangeValidator
{
protected $interchange;
protected $validators = array();
/**
* @param $interchange Instance of HTMLPurifier_ConfigSchema_Interchange
* to save changes to.
*/
public function __construct($interchange) {
$this->interchange = $interchange;
}
/**
* Registers a HTMLPurifier_ConfigSchema_Validator to run when adding.
*/
public function addValidator($validator) {
$this->validators[] = $validator;
}
/**
* Validates and adds a namespace hash
*/
public function addNamespace($hash) {
foreach ($this->validators as $validator) {
$validator->validateNamespace($hash, $this->interchange);
}
$this->interchange->addNamespace($hash);
}
/**
* Validates and adds a directive hash
*/
public function addDirective($hash) {
foreach ($this->validators as $validator) {
$validator->validateDirective($hash, $this->interchange);
}
$this->interchange->addDirective($hash);
}
}