Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML/YML support #9

Open
gfreeau opened this issue May 17, 2014 · 1 comment
Open

XML/YML support #9

gfreeau opened this issue May 17, 2014 · 1 comment

Comments

@gfreeau
Copy link

gfreeau commented May 17, 2014

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.

@gfreeau
Copy link
Author

gfreeau commented May 17, 2014

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 &lt;b&gt;name&lt;/b&gt;email@mail.com

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant