Skip to content

Commit

Permalink
Merge pull request #3477 from insiders/domain-router-null
Browse files Browse the repository at this point in the history
[MultiDomainBundle] Prevent duplicate calls for getting node translation
  • Loading branch information
acrobat authored Jan 31, 2025
2 parents ea6114c + 058cb5d commit 39771bb
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/Kunstmaan/MultiDomainBundle/Router/DomainBasedLocaleRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,25 @@ protected function getRequestLocale()
protected function getNodeTranslation($matchResult)
{
$key = $matchResult['_controller'] . $matchResult['url'] . $matchResult['_locale'] . $matchResult['_route'];
if (!isset($this->cachedNodeTranslations[$key])) {
$rootNode = $this->domainConfiguration->getRootNode();

// Lookup node translation
$nodeTranslationRepo = $this->getNodeTranslationRepository();

/* @var NodeTranslation $nodeTranslation */
$nodeTranslation = $nodeTranslationRepo->getNodeTranslationForUrl(
$matchResult['url'],
$matchResult['_locale'],
false,
null,
$rootNode
);
$this->cachedNodeTranslations[$key] = $nodeTranslation;
if (\array_key_exists($key, $this->cachedNodeTranslations)) {
return $this->cachedNodeTranslations[$key];
}

return $this->cachedNodeTranslations[$key];
$rootNode = $this->domainConfiguration->getRootNode();

// Lookup node translation
$nodeTranslationRepo = $this->getNodeTranslationRepository();

/* @var NodeTranslation $nodeTranslation */
$nodeTranslation = $nodeTranslationRepo->getNodeTranslationForUrl(
$matchResult['url'],
$matchResult['_locale'],
false,
null,
$rootNode
);

return $this->cachedNodeTranslations[$key] = $nodeTranslation;
}

private function isMultiDomainHost(): bool
Expand Down

0 comments on commit 39771bb

Please sign in to comment.