dms-filter
dms-filter copied to clipboard
XML/YML support
The README states this is only configured with annotations, it seems the config could also be loaded from yml/xml as well to make it more inline with other components such as validator or doctrine.
What are the chances of this?
The current loader seems to be similar to how the symfony validation component does it for annotations.
Sample xml config could be
<?xml version="1.0" encoding="UTF-8" ?>
<filter-mapping>
<class name="App\Entity\User">
<property name="name">
<rule name="StripTags">
<option name="allowed"><![CDATA[<b>,<i>]]></option>
</rule>
<rule name="Zend">
<option name="class">Zend\Filter\HtmlEntities</option>
<option name="zendOptions">
<option name="doublequote">false</option>
</option>
</rule>
<rule name="Trim"/>
<rule name="StripNewlines"/>
</property>
<property name="email">
<rule name="StripTags"/>
<rule name="Trim"/>
<rule name="StripNewlines"/>
</property>
</class>
</filter-mapping>
example yaml config:
App\Entity\User:
properties:
name:
- StripTags: {allowed: '<b>'}
- Zend:
class: 'Zend\Filter\HtmlEntities'
zendOptions: {doublequote: false}
- Trim: ~
- StripNewlines: ~
email:
- Zend: {class: 'Zend\Filter\HtmlEntities', zendOptions: {doublequote: false}}
- StripTags: ~
- Trim: ~
- StripNewlines: ~
I committed some changes to a fork: https://github.com/gfreeau/dms-filter/commits/feature-config-formats and made a sample test file: https://gist.github.com/gfreeau/9d8df717026c2ddc7dcc
output of the test is
My <b>name</b>[email protected]
A lot of the code is similar to what is already in the validation component, there is a possibility of some re-use there if it were re-factored.
I just need to add support for loader chains to load multiple xml/yml files and add some tests.