BaseHtmlPurifier.php 979 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
 * BaseHtmlPurifier provides concrete implementation for [[HtmlPurifier]].
11
 *
12
 * Do not use BaseHtmlPurifier. Use [[HtmlPurifier]] instead.
13 14 15 16
 *
 * @author Alexander Makarov <sam@rmcreative.ru>
 * @since 2.0
 */
17
class BaseHtmlPurifier
18
{
19 20 21
    /**
     * Passes markup through HTMLPurifier making it safe to output to end user
     *
22 23
     * @param string $content
     * @param array|null $config
24 25 26 27 28 29 30 31 32 33 34
     * @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);
    }
35
}