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

Commit ec05a6f

Browse files
committed
Merge pull request #167 from symfony-cmf/generic-intermediate-node-fixes
Fixes and changelog
2 parents 7b86bac + 9a725c9 commit ec05a6f

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

Adapter/PhpcrOdmAdapter.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,10 @@ public function getReferringAutoRoutes($contentDocument)
213213
*/
214214
public function findRouteForUri($uri, UriContext $uriContext)
215215
{
216-
$path = $this->getPathFromUri($uri);
217-
$document = $this->dm->find(null, $path);
218-
219-
if ($document instanceof AutoRouteInterface) {
220-
return $document;
221-
}
222-
223-
return null;
216+
return $this->dm->find(
217+
'Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface',
218+
$this->getPathFromUri($uri)
219+
);
224220
}
225221

226222
private function getPathFromUri($uri)

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
dev-master
5+
----------
6+
7+
* Convert non-managed intermediate nodes into AutoRoute documents #165
8+
49
1.0.0
510
-----
611

Tests/Unit/Adapter/PhpcrOdmAdapterTest.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function provideCompareRouteContent()
184184
public function testCompareRouteContent($isMatch)
185185
{
186186
$this->route->getContent()->willReturn($this->contentDocument);
187-
$content = $isMatch ? $this->contentDocument : $this->contentDocument2;
187+
$isMatch ? $this->contentDocument : $this->contentDocument2;
188188

189189
$this->adapter->compareAutoRouteContent($this->route->reveal(), $this->contentDocument);
190190
}
@@ -203,17 +203,9 @@ public function testFindRouteForUri()
203203
$uri = '/this/is/uri';
204204
$expectedRoute = $this->route->reveal();
205205

206-
$this->dm->find(null, $this->baseRoutePath . $uri)->willReturn($expectedRoute);
206+
$this->dm->find('Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface', $this->baseRoutePath . $uri)->willReturn($expectedRoute);
207207

208208
$res = $this->adapter->findRouteForUri($uri, $this->uriContext->reveal());
209209
$this->assertSame($expectedRoute, $res);
210210
}
211-
212-
public function testFindRouteForUriShouldReturnNullWhenNodeAtGivenPathIsNotAnAutoRoute()
213-
{
214-
$uri = '/this/is/uri';
215-
$genericNode = $this->prophesize('Doctrine\ODM\PHPCR\Document\Generic');
216-
$this->dm->find(null, $this->baseRoutePath . $uri)->willReturn($genericNode);
217-
$this->assertNull($this->adapter->findRouteForUri($uri, $this->uriContext->reveal()));
218-
}
219211
}

0 commit comments

Comments
 (0)