0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-24 01:01:53 +00:00
htmlpurifier/library/HTMLPurifier/ConfigSchema/InterchangeValidator.php
Edward Z. Yang 0d9c05d13c [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
2008-03-02 04:00:43 +00:00

46 lines
1.2 KiB
PHP

<?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);
}
}