Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit b2a1627

Browse files
committed
Only register validation metadata when PHPCR is enabled
1 parent 9f43e46 commit b2a1627

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

CmfMenuBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpKernel\Bundle\Bundle;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Cmf\Bundle\MenuBundle\DependencyInjection\Compiler\DecorateMenuFactoryPass;
17+
use Symfony\Cmf\Bundle\MenuBundle\DependencyInjection\Compiler\ValidationPass;
1718
use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass;
1819

1920
class CmfMenuBundle extends Bundle
@@ -23,6 +24,7 @@ public function build(ContainerBuilder $container)
2324
parent::build($container);
2425

2526
$container->addCompilerPass(new DecorateMenuFactoryPass());
27+
$container->addCompilerPass(new ValidationPass());
2628

2729
if (class_exists('Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass')) {
2830
$container->addCompilerPass(
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2015 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Cmf\Bundle\MenuBundle\DependencyInjection\Compiler;
13+
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
15+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
17+
/**
18+
* Register validation files only if their persistence layer is enabled.
19+
*
20+
* @author Wouter de Jong <[email protected]>
21+
*/
22+
class ValidationPass implements CompilerPassInterface
23+
{
24+
public function process(ContainerBuilder $container)
25+
{
26+
if ($container->hasParameter('cmf_menu.persistence.phpcr.menu_document_class')) {
27+
$container
28+
->getDefinition('validator.builder')
29+
->addMethodCall('addXmlMappings', [[__DIR__.'/../../Resources/config/validation-phpcr.xml']]);
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)