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
事实上,我不使用默认文件夹,而是将所有内容存储在特定站点中。我怎样才能检索“站点/我的站点/文件”呢?
解决方案
不是很优雅但有效:
$host = \Drupal::request()->getSchemeAndHttpHost();
$host .= "/sites/mysite/files";
推荐阅读
- json - 具有自定义键类型的 Data.Map.Strict.Map 的 Aeson 编码导致数组数组而不是对象
- javascript - 如何从 Firebase 函数 forEach 循环返回单个变量?
- .net - 如何计算 .net core Webapi 请求次数;
- typescript - TSLint:相对之前的绝对导入
- javascript - 带有 Babel 7 的 NuxtJS:在构建文件中仍然有扩展运算符
- c++ - 原子操作传播/可见性(原子负载与原子 RMW 负载)
- sql - SQL Server 2008 按唯一值获取最后一行
- ruby-on-rails - 从 URL 请求 Rails 模型的一部分
- javafx - 可以(Javafx)我使用 ComboBox 项目来显示页面吗?我需要将filmCombo组合框中的每个选项链接到一个fxml文件
- mysql - MySQL - 拆分分隔的右值和左值