public function UrlGenerator::generateFromRoute in Persistent URL 8
Parameters
string|\Symfony\Component\Routing\Route $name:
array $parameters:
array $options:
bool $collect_bubbleable_metadata:
Return value
\Drupal\Core\GeneratedUrl|string
Overrides UrlGeneratorInterface::generateFromRoute
File
- src/
Routing/ UrlGenerator.php, line 44
Class
Namespace
Drupal\purl\RoutingCode
public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) {
$hostOverride = null;
$originalHost = null;
if (isset($options['host']) && strlen((string) $options['host']) > 0) {
$hostOverride = $options['host'];
$originalHost = $this
->getContext()
->getHost();
$this
->getContext()
->setHost($hostOverride);
}
$result = $this->urlGenerator
->generateFromRoute($name, $parameters, $options, $collect_bubbleable_metadata);
// Reset the original host in request context.
if ($hostOverride) {
$this
->getContext()
->setHost($originalHost);
}
return $result;
}