Interchange.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Generic schema interchange format that can be converted to a runtime
  4. * representation (HTMLPurifier_ConfigSchema) or HTML documentation. Members
  5. * are completely validated.
  6. */
  7. class HTMLPurifier_ConfigSchema_Interchange
  8. {
  9. /**
  10. * Name of the application this schema is describing.
  11. */
  12. public $name;
  13. /**
  14. * Array of Directive ID => array(directive info)
  15. */
  16. public $directives = array();
  17. /**
  18. * Adds a directive array to $directives
  19. */
  20. public function addDirective($directive) {
  21. if (isset($this->directives[$i = $directive->id->toString()])) {
  22. throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'");
  23. }
  24. $this->directives[$i] = $directive;
  25. }
  26. /**
  27. * Convenience function to perform standard validation. Throws exception
  28. * on failed validation.
  29. */
  30. public function validate() {
  31. $validator = new HTMLPurifier_ConfigSchema_Validator();
  32. return $validator->validate($this);
  33. }
  34. }
  35. // vim: et sw=4 sts=4