private function InlineLinkExtractor::urlFromHref in Printer and PDF versions for Drupal 8+ 8
Same name and namespace in other branches
- 2.x src/LinkExtractor/InlineLinkExtractor.php \Drupal\printable\LinkExtractor\InlineLinkExtractor::urlFromHref()
Generate a URL object given a URL from the href attribute.
Tries external URLs first, if that fails it will attempt generation from a relative URL.
Parameters
string $href: The URL from the href attribute.
Return value
\Drupal\Core\Url The created URL object.
1 call to InlineLinkExtractor::urlFromHref()
- InlineLinkExtractor::extract in src/
LinkExtractor/ InlineLinkExtractor.php - Highlight hrefs from links in the given HTML string.
File
- src/
LinkExtractor/ InlineLinkExtractor.php, line 106
Class
- InlineLinkExtractor
- Link extractor.
Namespace
Drupal\printable\LinkExtractorCode
private function urlFromHref($href) {
try {
$url = Url::fromUri($href, [
'absolute' => TRUE,
]);
} catch (\InvalidArgumentException $e) {
$url = Url::fromUserInput($href, [
'absolute' => TRUE,
]);
}
return $url;
}