PHP code example of chrisshick / cakephp3-html-purifier

1. Go to this page and download the library: Download chrisshick/cakephp3-html-purifier library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chrisshick / cakephp3-html-purifier example snippets


    $this->addBehavior('ChrisShick/CakePHP3HtmlPurifier.HtmlPurifier', [
        'fields'=>['title','description']
    ]);

   $this->addBehavior('ChrisShick/CakePHP3HtmlPurifier.HtmlPurifier', [
        'events' => [
           Model.beforeMarshal => false,
           // you can also uncomment the line below to turn on the purifier only on the beforeSave event
           //Model.beforeSave => true,
        ]
   ]);

    $this->addBehavior('ChrisShick/CakePHP3HtmlPurifier.HtmlPurifier', [
        'events' => [
           Model.myCustomEvent => true,
        ]
   ]);

   $this->addBehavior('ChrisShick/CakePHP3HtmlPurifier.HtmlPurifier', [
        'config' => [
            'HTML' => [
                'DefinitionID' => 'purifiable',
                'DefinitionRev' => 1,
                'TidyLevel' => 'heavy',
                'Doctype' => 'XHTML 1.0 Transitional'
            ],
            'Core' => [
                'Encoding' => 'UTF-8'
            ],
            'AutoFormat' => [
                'RemoveSpansWithoutAttributes' => true,
                'RemoveEmpty' => true
            ],
        ],
   ]);