BaseHtmlPurifier.php 980 Bytes
Newer Older
1 2 3
<?php
/**
 * @link http://www.yiiframework.com/
Carsten Brandt committed
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5 6
 * @license http://www.yiiframework.com/license/
 */
Carsten Brandt committed
7

8
namespace yii\helpers;
9 10

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

        return $purifier->purify($content);
    }
36
}