Skip to content

Commit

Permalink
Fix sulu-link tag for internal link pages (#6484)
Browse files Browse the repository at this point in the history
* Set urls for internal link pages in ContentRepository

* Set urls only if mapping includes resolveUrl flag
  • Loading branch information
niklasnatter committed Feb 23, 2022
1 parent be36be2 commit 0556f12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,12 @@ public function testFindWithInternalLink()
$page->getUuid(),
'de',
'sulu_io',
MappingBuilder::create()->addProperties(['title'])->getMapping()
MappingBuilder::create()->addProperties(['title'])->setResolveUrl(true)->getMapping()
);

$this->assertEquals($page->getUuid(), $result->getId());
$this->assertEquals('/test-2', $result->getPath());
$this->assertEquals('/test-1', $result->getUrl());
$this->assertEquals('test-2', $result['title']);
}

Expand Down
5 changes: 5 additions & 0 deletions src/Sulu/Component/Content/Repository/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,11 @@ public function resolveInternalLinkContent(
$type
);

if ($mapping->resolveUrl()) {
$content->setUrl($linkedContent->getUrl());
$content->setUrls($linkedContent->getUrls());
}

if (!$content->getTemplate() || !$this->structureManager->getStructure($content->getTemplate())) {
$content->setBrokenTemplate();
}
Expand Down

0 comments on commit 0556f12

Please sign in to comment.