本文整理汇总了PHP中Drupal\Component\Utility\Html::transformRootRelativeUrlsToAbsolute方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::transformRootRelativeUrlsToAbsolute方法的具体用法?PHP Html::transformRootRelativeUrlsToAbsolute怎么用?PHP Html::transformRootRelativeUrlsToAbsolute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Component\Utility\Html
的用法示例。
在下文中一共展示了Html::transformRootRelativeUrlsToAbsolute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transformRootRelativeUrlsToAbsolute
/**
* Converts all root-relative URLs to absolute URLs in RSS markup.
*
* Does not change any existing protocol-relative or absolute URLs.
*
* @param string $rss_markup
* The RSS markup to update.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @return string
* The updated RSS markup.
*/
protected function transformRootRelativeUrlsToAbsolute($rss_markup, Request $request)
{
$rss_dom = new \DOMDocument();
$rss_dom->loadXML($rss_markup);
// Invoke Html::transformRootRelativeUrlsToAbsolute() on all HTML content
// embedded in this RSS feed.
foreach ($rss_dom->getElementsByTagName('description') as $node) {
$html_markup = $node->nodeValue;
if (!empty($html_markup)) {
$node->nodeValue = Html::transformRootRelativeUrlsToAbsolute($html_markup, $request->getSchemeAndHttpHost());
}
}
return $rss_dom->saveXML();
}