HTMLPurifier_ConfigSchema::add PHP Method

add() public method

Defines a directive for configuration
public add ( string $key, mixed $default, string $type, boolean $allow_null )
$key string Name of directive
$default mixed Default value of directive
$type string Allowed type of the directive. See HTMLPurifier_DirectiveDef::$type for allowed values
$allow_null boolean Whether or not to allow null values
    public function add($key, $default, $type, $allow_null)
    {
        $obj = new stdclass();
        $obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type];
        if ($allow_null) {
            $obj->allow_null = true;
        }
        $this->info[$key] = $obj;
        $this->defaults[$key] = $default;
        $this->defaultPlist->set($key, $default);
    }

Usage Example

コード例 #1
0
ファイル: ConfigSchema.php プロジェクト: gitanton/cono-rest
 public function build($interchange)
 {
     $schema = new HTMLPurifier_ConfigSchema();
     foreach ($interchange->directives as $d) {
         $schema->add($d->id->key, $d->default, $d->type, $d->typeAllowsNull);
         if ($d->allowed !== NULL) {
             $schema->addAllowedValues($d->id->key, $d->allowed);
         }
         foreach ($d->aliases as $alias) {
             $schema->addAlias($alias->key, $d->id->key);
         }
         if ($d->valueAliases !== NULL) {
             $schema->addValueAliases($d->id->key, $d->valueAliases);
         }
     }
     $schema->postProcess();
     return $schema;
 }