/** * Create node translation route. * * @param NodeTranslationInterface $translation * * @return RouteInterface */ public function create(NodeTranslationInterface $translation) { $locale = $translation->getLang(); $node = $translation->getNode(); $route = $this->routeManager->create(); $route->setRoutePattern($this->routerHelper->getRoutePattern($translation->getTitle(), $node, $locale)); $this->routeGenerator->generateRoute($route, $node, $locale); $this->routeManager->add($route); return $route; }
public function testGetRoutePatternWithParent() { $node = $this->getMockNode(); $parent = $this->getMockNode(); $this->addNodeType('test', $node); $this->addNodeParent($parent, $node); $this->assertEquals('/test', $this->routerHelper->getRoutePattern('test', $node, 'en')); $this->fillParent($parent, null); $this->assertEquals('/test', $this->routerHelper->getRoutePattern('test', $node, 'en')); $parentTranslation = $parent->getTranslation('en'); $this->addNodeTranslationTitle('Parent test', $parentTranslation); $this->assertEquals('/parent-test/test', $this->routerHelper->getRoutePattern('test', $node, 'en')); $parentParent = $this->getMockNode(); $this->addNodeParent($parentParent, $parent); $this->fillParent($parentParent, 'Parent parent test'); $this->assertEquals('/parent-parent-test/parent-test/test', $this->routerHelper->getRoutePattern('test', $node, 'en')); }