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

Commit a78896d

Browse files
authored
Merge pull request #278 from symfony-cmf/issue-277/validation
Only register validation metadata when PHPCR is enabled, adjust file structure
2 parents 9f43e46 + 6b1790f commit a78896d

File tree

72 files changed

+54
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+54
-16
lines changed

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
preset: symfony
2+
disabled: [single_line_class_definition]

.travis.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ sudo: false
1010

1111
cache:
1212
directories:
13+
- .phpunit
1314
- $HOME/.composer/cache/files
1415

1516
env:
16-
matrix: SYMFONY_VERSION=2.8.*
17-
global: SYMFONY_DEPRECATIONS_HELPER=321
17+
matrix: SYMFONY_VERSION=3.2.*
18+
global: SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
1819

1920
matrix:
2021
include:
21-
- php: 7.0
22-
env: DEPS=dev SYMFONY_VERSION=3.1.*
22+
- php: 7.1
23+
env: DEPS=dev SYMFONY_VERSION=3.3.*
2324
- php: 5.5
24-
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
25-
- php: 5.6
26-
env: DEPS=dev COMPOSER_FLAGS="--prefer-stable" SYMFONY_VERSION=3.0.*
25+
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
26+
- php: 7.1
27+
env: SYMFONY_VERSION=3.1.*
2728
fast_finish: true
2829

2930
before_install:

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
},
3434
"autoload": {
3535
"psr-4": {
36-
"Symfony\\Cmf\\Bundle\\MenuBundle\\": ""
36+
"Symfony\\Cmf\\Bundle\\MenuBundle\\": "src/"
37+
}
38+
},
39+
"autoload-dev": {
40+
"psr-4": {
41+
"Symfony\\Cmf\\Bundle\\MenuBundle\\Tests\\": "tests/"
3742
}
3843
},
3944
"extra": {

phpunit.xml.dist

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,20 @@
88

99
<testsuites>
1010
<testsuite name="Symfony CmfMenuBundle Test Suite">
11-
<directory>./Tests/Unit</directory>
11+
<directory>./tests/Unit</directory>
1212
</testsuite>
1313

1414
<testsuite name="phpcr">
15-
<directory>./Tests/Functional</directory>
15+
<directory>./tests/Functional</directory>
1616
</testsuite>
1717
</testsuites>
1818

1919
<filter>
2020
<whitelist addUncoveredFilesFromWhitelist="true">
21-
<directory>.</directory>
21+
<directory>src</directory>
2222
<exclude>
2323
<file>*Bundle.php</file>
2424
<directory>Resources/</directory>
25-
<directory>Admin/</directory>
26-
<directory>Tests/</directory>
27-
<directory>vendor/</directory>
2825
</exclude>
2926
</whitelist>
3027
</filter>
@@ -34,7 +31,7 @@
3431
</listeners>
3532

3633
<php>
37-
<server name="KERNEL_DIR" value="Tests/Resources/app" />
34+
<server name="KERNEL_DIR" value="tests/Resources/app" />
3835
</php>
3936

4037
</phpunit>

CmfMenuBundle.php renamed to src/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+
}
File renamed without changes.

0 commit comments

Comments
 (0)