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

Commit 00e2d1f

Browse files
committed
Added possiblity to register custom adapters
1 parent 29e2d88 commit 00e2d1f

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

DependencyInjection/Compiler/AutoRoutePass.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public function process(ContainerBuilder $container)
2929

3030
private function registerAdapter(ContainerBuilder $container)
3131
{
32+
if (!$container->hasDefinition(
33+
'cmf_routing_auto.auto_route_manager'
34+
)) {
35+
return;
36+
}
37+
3238
$adapter = $container->getParameter('cmf_routing_auto.adapter_name');
3339
$adapterId = null;
3440
$adapterNames = array();
@@ -57,6 +63,7 @@ private function registerAdapter(ContainerBuilder $container)
5763
));
5864
}
5965

66+
$managerDef = $container->getDefinition('cmf_routing_auto.auto_route_manager');
6067
$container->setAlias('cmf_routing_auto.adapter', $adapterId);
6168
}
6269

Doctrine/Phpcr/AutoRouteListener.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public function onFlush(ManagerEventArgs $args)
6969

7070
// refactor this.
7171
foreach ($uriContextCollection->getUriContexts() as $uriContext) {
72-
var_dump('123');
7372
$autoRoute = $uriContext->getAutoRoute();
7473
$dm->persist($autoRoute);
7574
$uow->computeChangeSets();

Tests/Unit/Adapter/PhpcrOdmAdapterTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ public function testCreateAutoRoute($path, $expectedParentPath, $expectedName, $
116116
}
117117

118118
$this->uriContext->getUri()->willReturn($path);
119+
<<<<<<< HEAD
119120

121+
=======
122+
>>>>>>> Added possiblity to register custom adapters
120123
$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'fr');
121124
$this->assertNotNull($res);
122125
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $res);
@@ -134,7 +137,11 @@ public function testCreateAutoRouteNonExistingBasePath()
134137
{
135138
$this->dm->getPhpcrSession()->willReturn($this->phpcrSession);
136139
$this->dm->find(null, $this->baseRoutePath)->willReturn(null);
140+
<<<<<<< HEAD
137141
$this->uriContext->getUri()->willReturn('/asdasd');
142+
=======
143+
$this->uriContext->getUri()->willReturn('/foo');
144+
>>>>>>> Added possiblity to register custom adapters
138145
$this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'fr');
139146
}
140147

Tests/Unit/DependencyInjection/CmfRoutingAutoExtensionTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ protected function loadPhpcrOdm()
3535
));
3636
}
3737

38-
/**
39-
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
40-
* @expectedExceptionMessage enable one of the persistence layers
41-
*/
42-
public function testLoad()
43-
{
44-
$this->setParameter('kernel.bundles', array());
45-
$this->load();
46-
}
47-
4838
public function testAutoMappingRegistration()
4939
{
5040
$this->loadPhpcrOdm();

Tests/Unit/DependencyInjection/Compiler/AutoRoutePassTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
77
use Symfony\Component\DependencyInjection\ContainerBuilder;
88
use Symfony\Component\DependencyInjection\Reference;
9+
use Symfony\Component\DependencyInjection\Alias;
910

1011
class AutoRoutePassTest extends AbstractCompilerPassTestCase
1112
{
@@ -55,13 +56,13 @@ public function testAdapterRegistration()
5556
$managerDef = new Definition();
5657
$managerDef->setArguments(array(0, 1, 2));
5758
$this->setDefinition('cmf_routing_auto.auto_route_manager', $managerDef);
58-
$this->container->setParameter('cmf_routing_auto.adapter', 'foobar');
59+
$this->container->setParameter('cmf_routing_auto.adapter_name', 'foobar');
5960

6061
$adapterDef = new Definition();
6162
$adapterDef->addTag('cmf_routing_auto.adapter', array('alias' => 'foobar'));
6263
$this->setDefinition('some_adapter', $adapterDef);
6364
$this->compile();
6465

65-
$this->assertEquals(new Reference('some_adapter'), $managerDef->getArgument(0));
66+
$this->assertEquals(new Alias('some_adapter'), $this->container->getAlias('cmf_routing_auto.adapter'));
6667
}
6768
}

0 commit comments

Comments
 (0)