Symfony2 validation component from XML

I am trying to use the Symfony2 validation component in a pre-existing framework which has an existing form handling system done using XSLT.

sample from : http://symfony.com/doc/master/book/validation.html
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

    <class name="MyClassName">
        <property name="name">
            <constraint name="NotBlank" />
        </property>
        <property name="name">
            <constraint name="NotBlank" />
        </property>
    </class>
</constraint-mapping>

I would like to populate the symfony2 validator with constraints loaded from an XML file. I have found the XMLFileLoader (http://api.symfony.com/2.3/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.html) and the Validator ( http://api.symfony.com/2.3/Symfony/Component/Validator/Validator.html).

I am just having trouble connecting the dots in between. The Validator takes a MetadataFactory, ValidatorFactory and a translator to it's constructor. None of which seem to take an XMLFileLoader.

链接地址: http://www.djcxy.com/p/57886.html

上一篇: 自定义字段类型中的路径

下一篇: 来自XML的Symfony2验证组件