PHP code example of tgalopin / html-sanitizer-bundle
1. Go to this page and download the library: Download tgalopin/html-sanitizer-bundle 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/ */
tgalopin / html-sanitizer-bundle example snippets
use HtmlSanitizer\SanitizerInterface;
class MyService
{
private $sanitizer;
public function __construct(SanitizerInterface $sanitizer)
{
$this->sanitizer = $sanitizer;
}
// ...
}
use HtmlSanitizer\SanitizerInterface;
class MyController
{
public function index(SanitizerInterface $sanitizer)
{
// ...
}
}
use Psr\Container\ContainerInterface;
class MyService
{
public function __construct(ContainerInterface $sanitizers)
{
// $sanitizers->get('admin_content') ...
}
}
class MyFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('content', TextareaType::class, ['sanitize_html' => true])
;
}
}
class MyFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('content', TextareaType::class, ['sanitize_html' => true, 'sanitizer' => 'admin_content'])
;
}
}