public function addValidationMapping(BaseValidatorBuilderInterface $builder, $dirs)
    {
        if (empty($dirs)) {
            return;
        }

        $finder = Finder::create()
            ->files()
            ->filter(function (\SplFileInfo $file) {
                return 1 === substr_count($file->getBasename(), '.') && preg_match('/validation\.(yml|yaml|xml)$/', $file->getBasename());
            })
            ->in($dirs)
        ;

        foreach ($finder as $file) {
            list($basename, $extension) = $parts = explode('.', $file->getBasename(), 3);

            switch ($extension) {
                case 'yml':
                case 'yaml':
                    $builder->addYamlMapping($file->getPathname());
                    break;
                case 'xml':
                    $builder->addXmlMapping($file->getPathname());
                    break;
            }
        }
    }
public function addValidationMapping(BaseValidatorBuilderInterface $builder, $dirs)
    {
        if (empty($dirs)) {
            return;
        }

        $finder = Finder::create()
            ->files()
            ->filter(function (\SplFileInfo $file) {
                return 1 === substr_count($file->getBasename(), '.') && preg_match('/validation\.(yml|yaml|xml)$/', $file->getBasename());
            })
            ->in($dirs)
        ;

        foreach ($finder as $file) {
            list($basename, $extension) = $parts = explode('.', $file->getBasename(), 3);

            switch ($extension) {
                case 'yml':
                case 'yaml':
                    $builder->addYamlMapping($file->getPathname());
                    break;
                case 'xml':
                    $builder->addXmlMapping($file->getPathname());
                    break;
            }
        }
    }
public function addValidationMapping ( BaseValidatorBuilderInterface $ builder , $ dirs ) { if ( empty ( $ dirs ) ) { return ; } $ finder = Finder :: create ( ) -> files ( ) -> filter ( function ( \ SplFileInfo $ file ) { return 1 === substr_count ( $ file -> getBasename ( ) , '.' ) && preg_match ( '/validation\.(yml|yaml|xml)$/' , $ file -> getBasename ( ) ) ; } ) -> in ( $ dirs ) ; foreach ( $ finder as $ file ) { list ( $ basename , $ extension ) = $ parts = explode ( '.' , $ file -> getBasename ( ) , 3 ) ; switch ( $ extension ) { case 'yml' : case 'yaml' : $ builder -> addYamlMapping ( $ file -> getPathname ( ) ) ; break ; case 'xml' : $ builder -> addXmlMapping ( $ file -> getPathname ( ) ) ; break ; } } }
add validation mapping

@param \Symfony\Component\Validator\ValidatorBuilderInterface  $builder
@param string|array  $dirs       A directory path or an array of directories
add validation mapping