加载validation.yml文件

时间:2012-07-30 10:40:17

标签: symfony

  

可能重复:
  In Symfony2, can the validation.yml file be split into multiple files using imports?

在yml文件中添加验证约束之前是否需要执行任何操作。 我很难在doc上找到有关如何加载validation.yml文件的信息:

# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author:
    properties:
        firstName:
            - NotBlank: ~
            - MinLength: 3

从验证文件加载验证约束的步骤是什么?

修改

public function load(array $configs, ContainerBuilder $container)
{
    $configuration = new Configuration();
    $config = $this->processConfiguration($configuration, $configs);

    $ymlValidationFile = $container  ->getParameter('validator.mapping.loader.yaml_files_loader.mapping_files');
    $ymlValidationFile[] = __DIR__.'/../Resources/config/validation.yml';
        $container->setParameter('validator.mapping.loader.yaml_files_loader.mapping_files',$ymlValidationFile);
}

1 个答案:

答案 0 :(得分:1)

我认为,beautiful doc完全解释了您的问题:)