Skip to content

Commit

Permalink
(fix) Use path property instead of rootPath
Browse files Browse the repository at this point in the history
Re #8

This PR seems to be needed for craft 5
  • Loading branch information
nitriques committed Sep 30, 2024
1 parent 40ecea3 commit cb779f7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace deuxhuithuit\cfstream;

use craft\elements\Asset;
use craft\helpers\App;

class Folder
{
Expand All @@ -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?
else if (property_exists($fs, 'rootPath')) {
$path = $fs->rootPath;
}


// Add the asset's folder path
$folderPath = $asset->getFolder()->path;
if ($folderPath) {
$path .= '/' . $folderPath;
Expand Down

0 comments on commit cb779f7

Please sign in to comment.