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

Commit e63393a

Browse files
committed
Added PHPCR route basepath option
1 parent 8ac2718 commit e63393a

File tree

10 files changed

+78
-1
lines changed

10 files changed

+78
-1
lines changed

DependencyInjection/CmfRoutingAutoExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function load(array $configs, ContainerBuilder $container)
4747
$paths[] = $path;
4848
}
4949
$container->setParameter('cmf_routing_auto.mapping.loader.resources', $paths);
50+
51+
if ($this->isConfigEnabled($container, $config['persistence']['phpcr'])) {
52+
$container->setParameter('cmf_routing_auto.persistence.phpcr.route_basepath', $config['persistence']['phpcr']['route_basepath']);
53+
}
5054
}
5155

5256
protected function findMappingFiles($bundles)

DependencyInjection/Configuration.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,29 @@ public function getConfigTreeBuilder()
4444
->end() // directories
4545
->end()
4646
->end() // mapping
47+
->append($this->getPersistenceNode())
4748
->end();
4849

4950
return $treeBuilder;
5051
}
52+
53+
protected function getPersistenceNode()
54+
{
55+
$builder = new TreeBuilder();
56+
$persistence = $builder->root('persistence');
57+
58+
$persistence
59+
->addDefaultsIfNotSet()
60+
->children()
61+
->arrayNode('phpcr')
62+
->addDefaultsIfNotSet()
63+
->canBeEnabled()
64+
->children()
65+
->scalarNode('route_basepath')->defaultValue('/cms/routes')->end()
66+
->end()
67+
->end() // phpcr
68+
->end();
69+
70+
return $persistence;
71+
}
5172
}

Resources/config/schema/routing-auto-1.0.xsd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,23 @@
1010
<xsd:complexType name="config">
1111
<xsd:sequence>
1212
<xsd:element name="mapping" type="mapping" minOccurs="0" />
13+
<xsd:element name="persistence" type="persistence" minOccurs="0" />
1314
</xsd:sequence>
1415

1516
<xsd:attribute name="auto-mapping" type="xsd:boolean" />
1617
</xsd:complexType>
1718

19+
<xsd:complexType name="persistence">
20+
<xsd:sequence>
21+
<xsd:element name="phpcr">
22+
<xsd:complexType>
23+
<xsd:attribute name="enabled" type="xsd:boolean" />
24+
<xsd:attribute name="route-basepath" type="xsd:string" />
25+
</xsd:complexType>
26+
</xsd:element>
27+
</xsd:sequence>
28+
</xsd:complexType>
29+
1830
<xsd:complexType name="mapping">
1931
<xsd:sequence>
2032
<xsd:element name="path" type="path" minOccurs="0" maxOccurs="unbounded" />

Tests/Resources/Fixtures/config/config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@
99
array('path' => 'Resources/config/foo.xml'),
1010
),
1111
),
12+
'persistence' => array(
13+
'phpcr' => array(
14+
'route_basepath' => '/routes',
15+
),
16+
),
1217
));

Tests/Resources/Fixtures/config/config.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@
99
<path path="Document/Post.php" type="annotation" />
1010
<path path="Resources/config/foo.xml" />
1111
</mapping>
12+
13+
<persistence>
14+
<phpcr route-basepath="/routes" />
15+
</persistence>
1216
</config>
1317
</container>

Tests/Resources/Fixtures/config/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ cmf_routing_auto:
55
- Resources/config/SpecificObject.yml
66
- { path: Document/Post.php, type: annotation }
77
- { path: Resources/config/foo.xml }
8+
persistence:
9+
phpcr:
10+
route_basepath: /routes
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services">
3+
4+
<config xmlns="http://cmf.symfony.com/schema/dic/routing_auto">
5+
6+
<persistence>
7+
<phpcr enabled="true" />
8+
</persistence>
9+
</config>
10+
</container>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services">
3+
4+
<config xmlns="http://cmf.symfony.com/schema/dic/routing_auto">
5+
6+
<persistence>
7+
<phpcr />
8+
</persistence>
9+
</config>
10+
</container>

Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public function testSupportsAllConfigFormats()
3838
array('path' => 'Resources/config/foo.xml', 'type' => null),
3939
),
4040
),
41+
'persistence' => array(
42+
'phpcr' => array(
43+
'enabled' => true,
44+
'route_basepath' => '/routes',
45+
),
46+
),
4147
);
4248

4349
$sources = array_map(function ($path) {

Tests/Unit/DependencyInjection/XmlSchemaTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ public function testSchema()
2020
$xmlFiles = array_map(function ($file) {
2121
return __DIR__.'/../../Resources/Fixtures/config/'.$file;
2222
}, array(
23-
'config1.xml',
2423
'config.xml',
24+
'config1.xml',
25+
'config2.xml',
26+
'config3.xml',
2527
));
2628

2729
$this->assertSchemaAcceptsXml($xmlFiles, __DIR__.'/../../../Resources/config/schema/routing-auto-1.0.xsd');

0 commit comments

Comments
 (0)