ConfigSchema.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. /**
  9. * @param HTMLPurifier_ConfigSchema_Interchange $interchange
  10. * @return HTMLPurifier_ConfigSchema
  11. */
  12. public function build($interchange)
  13. {
  14. $schema = new HTMLPurifier_ConfigSchema();
  15. foreach ($interchange->directives as $d) {
  16. $schema->add(
  17. $d->id->key,
  18. $d->default,
  19. $d->type,
  20. $d->typeAllowsNull
  21. );
  22. if ($d->allowed !== null) {
  23. $schema->addAllowedValues(
  24. $d->id->key,
  25. $d->allowed
  26. );
  27. }
  28. foreach ($d->aliases as $alias) {
  29. $schema->addAlias(
  30. $alias->key,
  31. $d->id->key
  32. );
  33. }
  34. if ($d->valueAliases !== null) {
  35. $schema->addValueAliases(
  36. $d->id->key,
  37. $d->valueAliases
  38. );
  39. }
  40. }
  41. $schema->postProcess();
  42. return $schema;
  43. }
  44. }
  45. // vim: et sw=4 sts=4