Created
July 18, 2017 09:43
-
-
Save alongosz/a6ca06dc34c7d8135503a3ee43751213 to your computer and use it in GitHub Desktop.
eZ\Bundle\EzPublishCoreBundle\Routing\DefaultRouter::generate suggestion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
$url = parent::generate($name, $parameters, $referenceType); | |
// Now putting back SiteAccess URI if needed. | |
if ($isSiteAccessAware && $siteAccess && $siteAccess->matcher instanceof URILexer) { | |
if ($referenceType === self::ABSOLUTE_URL || $referenceType === self::NETWORK_PATH) { | |
$scheme = $context->getScheme(); | |
$port = ''; | |
if ($scheme === 'http' && $this->context->getHttpPort() != 80) { | |
$port = ':' . $this->context->getHttpPort(); | |
} elseif ($scheme === 'https' && $this->context->getHttpsPort() != 443) { | |
$port = ':' . $this->context->getHttpsPort(); | |
} | |
$base = $context->getHost() . $port . $context->getBaseUrl(); | |
} else { | |
$base = $context->getBaseUrl(); | |
} | |
$linkUri = $base ? substr($url, strpos($url, $base) + strlen($base)) : $url; | |
$url = str_replace($linkUri, $siteAccess->matcher->analyseLink($linkUri), $url); | |
} | |
return $url; | |
} finally { | |
// Switch back to original context, for next links generation. | |
$this->setContext($originalContext); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment