Skip to content

Commit

Permalink
IBX-8088: Do not prepend siteaccess to URL if default
Browse files Browse the repository at this point in the history
  • Loading branch information
pspanja committed Apr 9, 2024
1 parent 82540f6 commit f8e939b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bundle/Core/Resources/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
- [setRequestContext, ["@router.request_context"]]
- [setSiteAccess, ['@?Ibexa\Core\MVC\Symfony\SiteAccess']]
- [setSiteAccessRouter, ['@Ibexa\Core\MVC\Symfony\SiteAccess\Router']]
- [setDefaultSiteAccessName, ['%ibexa.site_access.default%']]
- [setLogger, ["@?logger"]]

Ibexa\Bundle\Core\Routing\UrlAliasRouter:
Expand Down
9 changes: 8 additions & 1 deletion src/lib/MVC/Symfony/Routing/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ abstract class Generator implements SiteAccessAware
/** @var \Psr\Log\LoggerInterface */
protected $logger;

protected string $defaultSiteAccessName;

/**
* @param \Symfony\Component\Routing\RequestContext $requestContext
*/
Expand All @@ -54,6 +56,11 @@ public function setSiteAccess(SiteAccess $siteAccess = null)
$this->siteAccess = $siteAccess;
}

public function setDefaultSiteAccessName(string $name): void
{
$this->defaultSiteAccessName = $name;
}

/**
* @param \Psr\Log\LoggerInterface $logger
*/
Expand Down Expand Up @@ -92,7 +99,7 @@ public function generate($urlResource, array $parameters, $referenceType = UrlGe
$url = $this->doGenerate($urlResource, $parameters);

// Add the SiteAccess URI back if needed.
if ($siteAccess && $siteAccess->matcher instanceof SiteAccess\URILexer) {
if ($siteAccess && $siteAccess->matcher instanceof SiteAccess\URILexer && $siteAccess->name !== $this->defaultSiteAccessName) {
$url = $siteAccess->matcher->analyseLink($url);
}

Expand Down

0 comments on commit f8e939b

Please sign in to comment.