mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-01 11:50:28 +02:00
[3.1.0] Refactor out validation framework for Interchange
- Implement IdExists validator git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1584 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
43
library/HTMLPurifier/ConfigSchema/Interchange/Validator.php
Normal file
43
library/HTMLPurifier/ConfigSchema/Interchange/Validator.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base decorator class for HTMLPurifier_ConfigSchema_Interchange
|
||||
*/
|
||||
class HTMLPurifier_ConfigSchema_Interchange_Validator extends HTMLPurifier_ConfigSchema_Interchange
|
||||
{
|
||||
/**
|
||||
* Interchange object this schema is wrapping.
|
||||
*/
|
||||
protected $interchange;
|
||||
|
||||
/** @param Object to decorate */
|
||||
public function __construct($i = null) {
|
||||
$this->decorate($i);
|
||||
}
|
||||
|
||||
/** Wrap this decorator around an object. */
|
||||
public function decorate($i) {
|
||||
$this->interchange = $i;
|
||||
}
|
||||
|
||||
public function getNamespaces() {
|
||||
return $this->interchange->getNamespaces();
|
||||
}
|
||||
|
||||
public function getDirectives() {
|
||||
return $this->interchange->getDirectives();
|
||||
}
|
||||
|
||||
public function getTypes() {
|
||||
return $this->interchange->getTypes();
|
||||
}
|
||||
|
||||
public function addNamespace($arr) {
|
||||
$this->interchange->addNamespace($arr);
|
||||
}
|
||||
|
||||
public function addDirective($arr) {
|
||||
$this->interchange->addNamespace($arr);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_ConfigSchema_Interchange_Validator_IdExists extends HTMLPurifier_ConfigSchema_Interchange_Validator
|
||||
{
|
||||
|
||||
public function addNamespace($arr) {
|
||||
if (!isset($arr['ID'])) {
|
||||
throw new HTMLPurifier_ConfigSchema_Exception('Namespace must have ID');
|
||||
}
|
||||
parent::addNamespace($arr);
|
||||
}
|
||||
|
||||
public function addDirective($arr) {
|
||||
if (!isset($arr['ID'])) {
|
||||
throw new HTMLPurifier_ConfigSchema_Exception('Directive must have ID');
|
||||
}
|
||||
parent::addDirective($arr);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user