rokorolov / yii2-purifier-behavior
Purifier provides an ability to clean up HTML from any harmful code.
Installs: 7 882
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: >=2.0.6
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'] ] ], ]; }