File indexing completed on 2024-06-16 05:29:44

0001 <?php
0002 
0003 /**
0004  * Converts HTMLPurifier_ConfigSchema_Interchange to our runtime
0005  * representation used to perform checks on user configuration.
0006  */
0007 class HTMLPurifier_ConfigSchema_Builder_ConfigSchema
0008 {
0009 
0010     /**
0011      * @param HTMLPurifier_ConfigSchema_Interchange $interchange
0012      * @return HTMLPurifier_ConfigSchema
0013      */
0014     public function build($interchange)
0015     {
0016         $schema = new HTMLPurifier_ConfigSchema();
0017         foreach ($interchange->directives as $d) {
0018             $schema->add(
0019                 $d->id->key,
0020                 $d->default,
0021                 $d->type,
0022                 $d->typeAllowsNull
0023             );
0024             if ($d->allowed !== null) {
0025                 $schema->addAllowedValues(
0026                     $d->id->key,
0027                     $d->allowed
0028                 );
0029             }
0030             foreach ($d->aliases as $alias) {
0031                 $schema->addAlias(
0032                     $alias->key,
0033                     $d->id->key
0034                 );
0035             }
0036             if ($d->valueAliases !== null) {
0037                 $schema->addValueAliases(
0038                     $d->id->key,
0039                     $d->valueAliases
0040                 );
0041             }
0042         }
0043         $schema->postProcess();
0044         return $schema;
0045     }
0046 }
0047 
0048 // vim: et sw=4 sts=4