Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Apr 1, 2024
1 parent e711e36 commit 7aa55bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion moodle/Util/MoodleUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public static function getMoodleComponent(File $file, $selfPath = true): ?string
}
}

$filepath = MoodleUtil::getStandardisedFilename($file);
// Let's find the first component that matches the file path.
foreach ($components as $component => $componentPath) {
// Only components with path.
Expand All @@ -252,9 +253,10 @@ public static function getMoodleComponent(File $file, $selfPath = true): ?string
}

$componentPath = str_replace('\\', '/', $componentPath . DIRECTORY_SEPARATOR);
error_log("Checking {$componentPath} against {$filepath}");

// Look for component paths matching the file path.
if (strpos(MoodleUtil::getStandardisedFilename($file), $componentPath . DIRECTORY_SEPARATOR) === 0) {
if (strpos($filepath, $componentPath) === 0) {
// First match found should be the better one always. We are done.
return $component;
}
Expand Down

0 comments on commit 7aa55bd

Please sign in to comment.