drupal 8到特定站点的路径

时间:2019-04-25 10:52:07

标签: drupal drupal-8

我正在drupal 8网站上使用dompdf。我需要获取要放入其中的图像的绝对URL。

在生成我的pdf的控制器的方法中,我能够恢复路径:

$path = PublicStream::basePath();
// $path returns : sites/default/files 
$getpath = file_create_url($path); 
// $getpath returns : http://localhost/drupal/sites/default/files

实际上,我不使用默认文件夹,而是将所有内容存储在特定站点中。 我该如何检索“站点/我的站点/文件”

1 个答案:

答案 0 :(得分:0)

不是很优雅,但是很有效:

$host = \Drupal::request()->getSchemeAndHttpHost();
$host .= "/sites/mysite/files";
相关问题