Closed scottshipman closed 1 year ago
I had quite the same use case this morning. I had to play with the config for allowing a specific data-
attribute.
/**
* @return \HTMLPurifier
*/
protected function getPurifier()
{
if (null === $this->purifier) {
$this->purifier = new \HTMLPurifier($this->config);
$def = $this->purifier->config->getHTMLDefinition(true);
$def->info_global_attr['data-entity-file'] = new \HTMLPurifier_AttrDef_Text;
}
return $this->purifier;
}
I had to write my own Data transformer in order to allow the use of iframe's with attribute: allowfullscreen because its not part of the out of the box HTMLPurifier attribute set.
My data transformer models the HTMLPurifierTransformer, with the method getPurifier as below:
...where $config is passed in from the service container by getting the HTML_purifier config parameter from config.yml (or whereever its stored). In my case it was based on my own app bundle's extension.
Maybe your bundle can be extended to include a process where there is a config tree that looks like:
or something similar so the HTMLpurifier can be extended to take advantage of all possible customizations?