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

/**
10
 * HtmlPurifierBase provides concrete implementation for [[HtmlPurifier]].
11
 *
12
 * Do not use HtmlPurifierBase. Use [[HtmlPurifier]] instead.
13 14 15 16
 *
 * @author Alexander Makarov <sam@rmcreative.ru>
 * @since 2.0
 */
17
class HtmlPurifierBase
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);
	}
}