File indexing completed on 2024-12-22 05:36:19

0001 <?php
0002 
0003 /**
0004  * Generic schema interchange format that can be converted to a runtime
0005  * representation (HTMLPurifier_ConfigSchema) or HTML documentation. Members
0006  * are completely validated.
0007  */
0008 class HTMLPurifier_ConfigSchema_Interchange
0009 {
0010 
0011     /**
0012      * Name of the application this schema is describing.
0013      * @type string
0014      */
0015     public $name;
0016 
0017     /**
0018      * Array of Directive ID => array(directive info)
0019      * @type HTMLPurifier_ConfigSchema_Interchange_Directive[]
0020      */
0021     public $directives = array();
0022 
0023     /**
0024      * Adds a directive array to $directives
0025      * @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive
0026      * @throws HTMLPurifier_ConfigSchema_Exception
0027      */
0028     public function addDirective($directive)
0029     {
0030         if (isset($this->directives[$i = $directive->id->toString()])) {
0031             throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'");
0032         }
0033         $this->directives[$i] = $directive;
0034     }
0035 
0036     /**
0037      * Convenience function to perform standard validation. Throws exception
0038      * on failed validation.
0039      */
0040     public function validate()
0041     {
0042         $validator = new HTMLPurifier_ConfigSchema_Validator();
0043         return $validator->validate($this);
0044     }
0045 }
0046 
0047 // vim: et sw=4 sts=4