mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-13 00:38:42 +00:00
46 lines
1.2 KiB
PHP
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);
|
||
|
}
|
||
|
}
|