PHP code example of atwx / silverstripe-htmlfield-cleaner
1. Go to this page and download the library: Download atwx/silverstripe-htmlfield-cleaner 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/ */
atwx / silverstripe-htmlfield-cleaner example snippets
use Atwx\HtmlFieldCleaner\Preprocessors\Preprocessor;
use DOMDocumentFragment;
class MyPreprocessor implements Preprocessor
{
public function process(DOMDocumentFragment $fragment): void
{
// manipulate $fragment
}
}
use Atwx\HtmlFieldCleaner\HtmlFieldCleaner;
$clean = HtmlFieldCleaner::singleton()->clean($html);
$clean = HtmlFieldCleaner::singleton()->clean($html, ['attribute_whitelist' => ['style' => true]]);
sh
vendor/bin/phpunit vendor/atwx/silverstripe-htmlfield-cleaner/tests/php