What is or might be the best practice to integrate the HTMLPurifier in Zend Framework 2? The goal is to filter Zend Form Elements and input fields, which where not generated with Zend Form.

How would you do this?

有帮助吗?

解决方案

From my point of view I would say you can create a new filter. If Purifier were already a 'part' of Zend then it might be name Zend\Filter\HtmlPurifier. That's where I see it fitting the most.

You could also make it a Validator (Zend\Validator\HtmlPurifier) so you can tell if a piece of text 'passes' or not. Depends on what you want to do.

If you want to reject bad input, use the validator path. If you want to filter out bad input use the filter path.

After you've made your Zend filter/validator, use it like you would any other filter/validator.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top