getChildDef() public method

Retrieves a proper HTMLPurifier_ChildDef subclass based on content_model and content_model_type member variables of the HTMLPurifier_ElementDef class. There is a similar function in HTMLPurifier_HTMLDefinition.
public getChildDef ( HTMLPurifier_ElementDef $def ) : HTMLPurifier_ChildDef
$def HTMLPurifier_ElementDef
return HTMLPurifier_ChildDef subclass
 /**
  * Instantiates a ChildDef based on content_model and content_model_type
  * member variables in HTMLPurifier_ElementDef
  * @note This will also defer to modules for custom HTMLPurifier_ChildDef
  *       subclasses that need content set expansion
  * @param HTMLPurifier_ElementDef $def HTMLPurifier_ElementDef to have ChildDef extracted
  * @param HTMLPurifier_HTMLModule $module Module that defined the ElementDef
  * @return HTMLPurifier_ChildDef corresponding to ElementDef
  */
 public function getChildDef($def, $module)
 {
     $value = $def->content_model;
     if (is_object($value)) {
         trigger_error('Literal object child definitions should be stored in ' . 'ElementDef->child not ElementDef->content_model', E_USER_NOTICE);
         return $value;
     }
     switch ($def->content_model_type) {
         case 'required':
             return new HTMLPurifier_ChildDef_Required($value);
         case 'optional':
             return new HTMLPurifier_ChildDef_Optional($value);
         case 'empty':
             return new HTMLPurifier_ChildDef_Empty();
         case 'custom':
             return new HTMLPurifier_ChildDef_Custom($value);
     }
     // defer to its module
     $return = false;
     if ($module->defines_child_def) {
         // save a func call
         $return = $module->getChildDef($def);
     }
     if ($return !== false) {
         return $return;
     }
     // error-out
     trigger_error('Could not determine which ChildDef class to instantiate', E_USER_ERROR);
     return false;
 }