Created
October 14, 2013 11:55
-
-
Save K-Phoen/6974497 to your computer and use it in GitHub Desktop.
How to split the validation.yml file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\BlogBundle\DependencyInjection; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | |
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | |
use Symfony\Component\Config\FileLocator; | |
class AcmeBlogExtension extends Extension | |
{ | |
public function load(array $configs, ContainerBuilder $container) | |
{ | |
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | |
$loader->load('services.yml'); | |
$loader->load('listeners.yml'); | |
$this->loadValidationConfiguration($container); | |
} | |
protected function loadValidationConfiguration(ContainerBuilder $container) | |
{ | |
$yamlMappingFiles = $container->getParameter('validator.mapping.loader.yaml_files_loader.mapping_files'); | |
$yamlMappingFiles[] = __DIR__.'/../Resources/config/validation/Post.yml'; | |
$yamlMappingFiles[] = __DIR__.'/../Resources/config/validation/Comment.yml'; | |
$container->setParameter('validator.mapping.loader.yaml_files_loader.mapping_files', $yamlMappingFiles); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Acme\BlogBundle\Entity\Comment | |
properties: | |
username: | |
- NotBlank: ~ | |
- MaxLength: 50 | |
email: | |
- Email: ~ | |
comment: | |
- NotBlank: ~ | |
- MinLength: 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Acme\BlogBundle\Entity\Post: | |
properties: | |
title: | |
- NotBlank: ~ | |
body: | |
- MinLength: 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Acme\BlogBundle\Entity\Comment | |
properties: | |
username: | |
- NotBlank: ~ | |
- MaxLength: 50 | |
email: | |
- Email: ~ | |
comment: | |
- NotBlank: ~ | |
- MinLength: 50 | |
Acme\BlogBundle\Entity\Post: | |
properties: | |
title: | |
- NotBlank: ~ | |
body: | |
- MinLength: 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment