HtmlPurifier.php 962 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
<?php
/**
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @link http://www.yiiframework.com/
 * @license http://www.yiiframework.com/license/
 */
namespace yii\helpers\base;

/**
10
 * HtmlPurifier is the concrete implementation of the [[yii\helpers\HtmlPurifier]] class.
11
 *
12
 * You should use [[yii\helpers\HtmlPurifier]] instead of this class in your application.
13 14 15 16
 *
 * @author Alexander Makarov <sam@rmcreative.ru>
 * @since 2.0
 */
17
class HtmlPurifier
18
{
Alexander Makarov committed
19 20 21 22 23 24 25
	/**
	 * Passes markup through HTMLPurifier making it safe to output to end user
	 *
	 * @param string $content
	 * @param array|null $config
	 * @return string
	 */
26 27
	public static function process($content, $config = null)
	{
28 29 30
		$configInstance = \HTMLPurifier_Config::create($config);
		$configInstance->autoFinalize = false;
		$purifier=\HTMLPurifier::instance($configInstance);
31 32 33 34
		$purifier->config->set('Cache.SerializerPath', \Yii::$app->getRuntimePath());
		return $purifier->purify($content);
	}
}