rokorolov/yii2-purifier-behavior

This package is abandoned and no longer maintained. The author suggests using the abandoned/yii2-purifier-behavior package instead.

Purifier provides an ability to clean up HTML from any harmful code.

v1.0.0 2016-01-25 09:20 UTC

This package is not auto-updated.

Last update: 2022-09-22 19:24:26 UTC


README

Purifier provides an ability to clean up HTML from any harmful code.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist rokorolov/yii2-purifier-behavior "*"

or add

"rokorolov/yii2-purifier-behavior": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

Attach a behavior to model and configure.

use rokorolov\purifier\PurifierBehavior;

public function behaviors() 
{
    return [
        // ...
        'purifierBehavior' => [
            'class' => PurifierBehavior::className(),
            'attributes' => [
                self::EVENT_BEFORE_UPDATE => ['description'],
                self::EVENT_BEFORE_INSERT => ['description'],
            ],
            'textAttributes' => [
                self::EVENT_BEFORE_UPDATE => ['title', 'slug'],
                self::EVENT_BEFORE_INSERT => ['title', 'slug']
            ]
        ],
    ];
}