From d52d1ecdf826036aa35215cb8cf9080bbff71db6 Mon Sep 17 00:00:00 2001 From: Nicolas Brassard Date: Mon, 30 Sep 2024 16:50:52 -0400 Subject: [PATCH] (fix) Use `path` property instead of `rootPath` (#13) * (fix) Use path property instead of rootPath Re #8 This PR seems to be needed for craft 5 * Format code --- src/Folder.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Folder.php b/src/Folder.php index 4819903..ea50b2c 100644 --- a/src/Folder.php +++ b/src/Folder.php @@ -3,6 +3,7 @@ namespace deuxhuithuit\cfstream; use craft\elements\Asset; +use craft\helpers\App; class Folder { @@ -15,11 +16,17 @@ public static function getAssetFolderPath($asset): string { $fs = $asset->getVolume()->getFs(); $path = ''; - - if (property_exists($fs, 'rootPath')) { + + // Start with the volume's path + if ($fs->path) { + $path = App::parseEnv($fs->path); + } + // or start with rootPath, if it exists? + elseif (property_exists($fs, 'rootPath')) { $path = $fs->rootPath; } - + + // Add the asset's folder path $folderPath = $asset->getFolder()->path; if ($folderPath) { $path .= '/' . $folderPath;