【问题标题】:drupal 8 path to a specific site特定站点的drupal 8路径
【发布时间】:2019-04-25 10:52:06
【问题描述】:

我在 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

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

【问题讨论】:

    标签: drupal drupal-8


    【解决方案1】:

    不是很优雅但很有效:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-19
      • 2019-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多