You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

7 years ago
  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. * @type string
  12. */
  13. public $name;
  14. /**
  15. * Array of Directive ID => array(directive info)
  16. * @type HTMLPurifier_ConfigSchema_Interchange_Directive[]
  17. */
  18. public $directives = array();
  19. /**
  20. * Adds a directive array to $directives
  21. * @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive
  22. * @throws HTMLPurifier_ConfigSchema_Exception
  23. */
  24. public function addDirective($directive)
  25. {
  26. if (isset($this->directives[$i = $directive->id->toString()])) {
  27. throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'");
  28. }
  29. $this->directives[$i] = $directive;
  30. }
  31. /**
  32. * Convenience function to perform standard validation. Throws exception
  33. * on failed validation.
  34. */
  35. public function validate()
  36. {
  37. $validator = new HTMLPurifier_ConfigSchema_Validator();
  38. return $validator->validate($this);
  39. }
  40. }
  41. // vim: et sw=4 sts=4