/** * Returns the singleton instance of HTML Purifier. If no instance has * been created, a new instance will be created. * * $purifier = Purifier::instance(); * * @return HTMLPurifier */ public static function instance() { if (!Purifier::$singleton) { if (!class_exists('HTMLPurifier_Config', false)) { if (Config::get('purifier::config.preload')) { // Load the all of HTML Purifier right now. // This increases performance with a slight hit to memory usage. require base_path('vendor/ezyang/htmlpurifier/library/') . 'HTMLPurifier.includes.php'; } // Load the HTML Purifier auto loader require base_path('vendor/ezyang/htmlpurifier/library/') . 'HTMLPurifier.auto.php'; } // Create a new configuration object $config = HTMLPurifier_Config::createDefault(); // Allow configuration to be modified if (!Config::get('purifier::config.finalize')) { $config->autoFinalize = false; } // Use the same character set as Laravel $config->set('Core.Encoding', Config::get('purifier::config.encoding')); if (is_array(Config::get('purifier::config.settings.default'))) { // Load the settings $config->loadArray(Config::get('purifier::config.settings.default')); } // Configure additional options $config = Purifier::configure($config); Purifier::$configs['default'] = $config; // Create the purifier instance Purifier::$singleton = new HTMLPurifier($config); } return Purifier::$singleton; }
/** * Modifies the configuration before creating a HTML Purifier instance. * * [!!] You must create an extension and overload this method to use it. * * @param \Mews\Purifier\HTMLPurifier_Config configuration object * @return \Mews\Purifier\HTMLPurifier_Config * @static */ public static function configure($config) { return \Mews\Purifier\Purifier::configure($config); }