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

Commit 1fb5557

Browse files
committed
1.1 Release
1 parent 1470959 commit 1fb5557

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
lines changed

Adapter/PhpcrOdmAdapter.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function removeAutoRoute(AutoRouteInterface $autoRoute)
109109
/**
110110
* {@inheritdoc}
111111
*/
112-
public function createAutoRoute(UriContext $uriContext, $contentDocument, $autoRouteTag)
112+
public function createAutoRoute($uri, $contentDocument, $autoRouteTag)
113113
{
114114
$basePath = $this->baseRoutePath;
115115
$document = $parentDocument = $this->dm->find(null, $basePath);
@@ -119,8 +119,7 @@ public function createAutoRoute(UriContext $uriContext, $contentDocument, $autoR
119119
$basePath
120120
));
121121
}
122-
123-
$segments = preg_split('#/#', $uriContext->getUri(), null, PREG_SPLIT_NO_EMPTY);
122+
$segments = preg_split('#/#', $uri, null, PREG_SPLIT_NO_EMPTY);
124123
$headName = array_pop($segments);
125124
foreach ($segments as $segment) {
126125
$basePath .= '/'.$segment;
@@ -208,7 +207,7 @@ public function getReferringAutoRoutes($contentDocument)
208207
/**
209208
* {@inheritdoc}
210209
*/
211-
public function findRouteForUri($uri, UriContext $uriContext)
210+
public function findRouteForUri($uri)
212211
{
213212
return $this->dm->find(
214213
'Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface',

Command/RefreshCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function configure()
2525
$this
2626
->setName('cmf:routing:auto:refresh')
2727
->setDescription('Refresh auto-routeable documents')
28-
->setHelp(<<<HERE
28+
->setHelp(<<<'HERE'
2929
WARNING: Experimental!
3030
3131
This command iterates over all Documents that are mapped by the auto

Doctrine/Phpcr/AutoRouteListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function endFlush(ManagerEventArgs $args)
115115
private function isAutoRouteable($document)
116116
{
117117
try {
118-
return (boolean) $this->getMetadataFactory()->getMetadataForClass(get_class($document));
118+
return (bool) $this->getMetadataFactory()->getMetadataForClass(get_class($document));
119119
} catch (ClassNotMappedException $e) {
120120
return false;
121121
}

Model/AutoRoute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function setType($type)
5656
/**
5757
* {@inheritdoc}
5858
*/
59-
public function setRedirectTarget($redirectRoute)
59+
public function setRedirectTarget(AutoRouteInterface $redirectRoute)
6060
{
6161
$this->redirectRoute = $redirectRoute;
6262
}

Tests/Functional/EventListener/AutoRouteListenerTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,33 @@ public function testLeaveRedirectChildrenMigrations()
462462
$this->assertCount(1, $this->getDm()->getChildren($newRoute));
463463
}
464464

465+
/**
466+
* It should leave redirect routes in their original parent directories if the
467+
* schema is updated to change the parent directory/path.
468+
*/
469+
public function testMaintainRedirectParentPath()
470+
{
471+
$article1 = new SeoArticle();
472+
$article1->title = 'Hai';
473+
$article1->path = '/test/article-1';
474+
$this->getDm()->persist($article1);
475+
$this->getDm()->flush();
476+
477+
$parentRoute = $this->getDm()->find(null, '/test/auto-route');
478+
$autoRoute = $this->getDm()->find(null, '/test/auto-route/seo-articles/hai');
479+
$autoRoute->setParent($parentRoute);
480+
$this->getDm()->persist($autoRoute);
481+
$this->getDm()->flush();
482+
483+
$article1->title = 'Hoff';
484+
$this->getDm()->persist($article1);
485+
$this->getDm()->flush();
486+
487+
$autoRoute = $this->getDm()->find(null, '/test/auto-route/hai');
488+
$this->assertNotNull($autoRoute);
489+
$this->assertEquals(AutoRouteInterface::TYPE_REDIRECT, $autoRoute->getDefault('type'));
490+
}
491+
465492
/**
466493
* Ensure that we can map parent classes: #56.
467494
*/

Tests/Unit/Adapter/PhpcrOdmAdapterTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ public function testCreateAutoRoute($path, $expectedParentPath, $expectedName, $
116116
->willReturn(null);
117117
}
118118

119-
$this->uriContext->getUri()->willReturn($path);
120-
$res = $this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'fr');
119+
$res = $this->adapter->createAutoRoute($path, $this->contentDocument, 'fr');
121120
$this->assertNotNull($res);
122121
$this->assertInstanceOf('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute', $res);
123122
$this->assertEquals($expectedName, $res->getName());
@@ -147,8 +146,7 @@ public function testCreateAutoRouteThrowsExceptionIfItCannotMigrateExistingGener
147146
$genericDocument->reveal(),
148147
new \stdClass()
149148
);
150-
$this->uriContext->getUri()->willReturn($uri);
151-
$this->adapter->createAutoRoute($this->uriContext->reveal(), $this->contentDocument, 'it');
149+
$this->adapter->createAutoRoute($uri, $this->contentDocument, 'it');
152150
}
153151

154152
/**

0 commit comments

Comments
 (0)