4 * Performs validations on HTMLPurifier_ConfigSchema_Interchange
6 class HTMLPurifier_ConfigSchema_Validator
9 protected $interchange;
12 * Volatile context variables to provide a fluent interface.
14 protected $context, $obj, $member;
17 * Validates a fully-formed interchange object. Throws an
18 * HTMLPurifier_ConfigSchema_Exception if there's a problem.
20 public function validate($interchange) {
21 $this->interchange
= $interchange;
22 foreach ($interchange->namespaces
as $namespace) {
23 $this->validateNamespace($namespace);
25 foreach ($interchange->directives
as $directive) {
26 $this->validateDirective($directive);
30 public function validateNamespace($n) {
31 $this->context
= "namespace '{$n->namespace}'";
32 $this->with($n, 'namespace')
35 $this->with($n, 'description')
40 public function validateDirective($d) {
41 $this->context
= "directive '{$d->id}'";
42 $this->validateId($d->id
);
45 public function validateId($id) {
46 $this->context
= "id '$id'";
47 $this->with($id, 'namespace')
50 $this->with($id, 'directive')
55 // protected helper functions
57 protected function with($obj, $member) {
58 return new HTMLPurifier_ConfigSchema_ValidatorAtom($this->context
, $obj, $member);
61 protected function error($msg) {
62 throw new HTMLPurifier_ConfigSchema_Exception($msg . ' in ' . $this->context
);