HTMLPurifier_URISchemeRegistry::instance PHP Метод

instance() публичный статический Метод

Retrieve sole instance of the registry.
public static instance ( HTMLPurifier_URISchemeRegistry $prototype = null ) : HTMLPurifier_URISchemeRegistry
$prototype HTMLPurifier_URISchemeRegistry Optional prototype to overload sole instance with, or bool true to reset to default registry.
Результат HTMLPurifier_URISchemeRegistry
    public static function instance($prototype = null)
    {
        static $instance = null;
        if ($prototype !== null) {
            $instance = $prototype;
        } elseif ($instance === null || $prototype == true) {
            $instance = new HTMLPurifier_URISchemeRegistry();
        }
        return $instance;
    }

Usage Example

Пример #1
0
 /**
  * Retrieves a scheme object corresponding to the URI's scheme/default
  * @param $config Instance of HTMLPurifier_Config
  * @param $context Instance of HTMLPurifier_Context
  * @return Scheme object appropriate for validating this URI
  */
 function getSchemeObj($config, &$context)
 {
     $registry =& HTMLPurifier_URISchemeRegistry::instance();
     if ($this->scheme !== null) {
         $scheme_obj = $registry->getScheme($this->scheme, $config, $context);
         if (!$scheme_obj) {
             return false;
         }
         // invalid scheme, clean it out
     } else {
         // no scheme: retrieve the default one
         $def = $config->getDefinition('URI');
         $scheme_obj = $registry->getScheme($def->defaultScheme, $config, $context);
         if (!$scheme_obj) {
             // something funky happened to the default scheme object
             trigger_error('Default scheme object "' . $def->defaultScheme . '" was not readable', E_USER_WARNING);
             return false;
         }
     }
     return $scheme_obj;
 }
All Usage Examples Of HTMLPurifier_URISchemeRegistry::instance
HTMLPurifier_URISchemeRegistry