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:
45
library/HTMLPurifier/ConfigSchema/InterchangeValidator.php
Normal file
45
library/HTMLPurifier/ConfigSchema/InterchangeValidator.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user