protected function UiHelperTrait::buildUrl in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::buildUrl()
- 9 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::buildUrl()
Builds an absolute URL from a system path or a URL object.
Parameters
string|\Drupal\Core\Url $path: A system path or a URL.
array $options: Options to be passed to Url::fromUri().
Return value
string An absolute URL string.
7 calls to UiHelperTrait::buildUrl()
- BrowserTestBaseUserAgentTest::testUserAgentValidation in core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseUserAgentTest.php - Tests validation of the User-Agent header we use to perform test requests.
- BrowserWithJavascriptTest::drupalGetWithAlert in core/
tests/ Drupal/ FunctionalJavascriptTests/ BrowserWithJavascriptTest.php - Retrieves a Drupal path or an absolute path.
- DestinationTest::testDestination in core/
modules/ system/ tests/ src/ Functional/ Routing/ DestinationTest.php - Tests that $_GET/$_REQUEST['destination'] only contain internal URLs.
- SecurityAdvisoryTest::setUp in core/
modules/ system/ tests/ src/ Functional/ SecurityAdvisories/ SecurityAdvisoryTest.php - SessionHttpsTest::loginHttp in core/
modules/ system/ tests/ src/ Functional/ Session/ SessionHttpsTest.php - Log in a user via HTTP.
File
- core/
tests/ Drupal/ Tests/ UiHelperTrait.php, line 274
Class
- UiHelperTrait
- Provides UI helper methods.
Namespace
Drupal\TestsCode
protected function buildUrl($path, array $options = []) {
if ($path instanceof Url) {
$url_options = $path
->getOptions();
$options = $url_options + $options;
$path
->setOptions($options);
return $path
->setAbsolute()
->toString();
}
elseif (\Drupal::hasService('url_generator')) {
$force_internal = isset($options['external']) && $options['external'] == FALSE;
if (!$force_internal && UrlHelper::isExternal($path)) {
return Url::fromUri($path, $options)
->toString();
}
else {
$uri = $path === '<front>' ? 'base:/' : 'base:/' . $path;
// Path processing is needed for language prefixing. Skip it when a
// path that may look like an external URL is being used as internal.
$options['path_processing'] = !$force_internal;
return Url::fromUri($uri, $options)
->setAbsolute()
->toString();
}
}
else {
return $this
->getAbsoluteUrl($path);
}
}