ConfigSchema.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Converts HTMLPurifier_ConfigSchema_Interchange to our runtime
  4. * representation used to perform checks on user configuration.
  5. */
  6. class HTMLPurifier_ConfigSchema_Builder_ConfigSchema
  7. {
  8. public function build($interchange) {
  9. $schema = new HTMLPurifier_ConfigSchema();
  10. foreach ($interchange->directives as $d) {
  11. $schema->add(
  12. $d->id->key,
  13. $d->default,
  14. $d->type,
  15. $d->typeAllowsNull
  16. );
  17. if ($d->allowed !== null) {
  18. $schema->addAllowedValues(
  19. $d->id->key,
  20. $d->allowed
  21. );
  22. }
  23. foreach ($d->aliases as $alias) {
  24. $schema->addAlias(
  25. $alias->key,
  26. $d->id->key
  27. );
  28. }
  29. if ($d->valueAliases !== null) {
  30. $schema->addValueAliases(
  31. $d->id->key,
  32. $d->valueAliases
  33. );
  34. }
  35. }
  36. $schema->postProcess();
  37. return $schema;
  38. }
  39. }
  40. // vim: et sw=4 sts=4