fix sitemap generator: inject current domain when it's possible
This commit is contained in:
parent
8e06dab2b3
commit
53280aeccd
|
@ -69,6 +69,14 @@ class SitemapBuilder
|
||||||
public function getNodeUrls(Node $node, ?string $currentDomain)
|
public function getNodeUrls(Node $node, ?string $currentDomain)
|
||||||
{
|
{
|
||||||
$urls = [];
|
$urls = [];
|
||||||
|
$domain = $currentDomain;
|
||||||
|
$navigation = $node->getMenu()->getNavigation();
|
||||||
|
|
||||||
|
if (null === $currentDomain || $navigation->getForceDomain()) {
|
||||||
|
$domain = $navigation->getDomain();
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = ['_domain' => $domain];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($node->hasExternalUrl()) {
|
if ($node->hasExternalUrl()) {
|
||||||
|
@ -80,26 +88,21 @@ class SitemapBuilder
|
||||||
if (null === $annotation) {
|
if (null === $annotation) {
|
||||||
$urls[] = $this->urlGenerator->generate(
|
$urls[] = $this->urlGenerator->generate(
|
||||||
$node->getRouteName(),
|
$node->getRouteName(),
|
||||||
[],
|
$params,
|
||||||
UrlGeneratorInterface::ABSOLUTE_URL
|
UrlGeneratorInterface::ABSOLUTE_URL
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
$annotation->options = array_merge(
|
||||||
|
$params,
|
||||||
|
$annotation->options
|
||||||
|
);
|
||||||
|
|
||||||
$service = $this->container->get($annotation->service);
|
$service = $this->container->get($annotation->service);
|
||||||
$method = $annotation->method;
|
$method = $annotation->method;
|
||||||
$urls = $service->{$method}($node, $annotation->options);
|
$urls = $service->{$method}($node, $annotation->options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (!$node->getDisableUrl() && !$node->hasAppUrl()) {
|
} elseif (!$node->getDisableUrl() && !$node->hasAppUrl()) {
|
||||||
$params = [];
|
|
||||||
$domain = $currentDomain;
|
|
||||||
$navigation = $node->getMenu()->getNavigation();
|
|
||||||
|
|
||||||
if (null === $currentDomain || $navigation->getForceDomain()) {
|
|
||||||
$domain = $navigation->getDomain();
|
|
||||||
}
|
|
||||||
|
|
||||||
$params['_domain'] = $domain;
|
|
||||||
|
|
||||||
foreach ($node->getParameters() as $param) {
|
foreach ($node->getParameters() as $param) {
|
||||||
if ('_locale' === $param['name']) {
|
if ('_locale' === $param['name']) {
|
||||||
$params['_locale'] = !empty($param['defaultValue'])
|
$params['_locale'] = !empty($param['defaultValue'])
|
||||||
|
|
Loading…
Reference in a new issue