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 e592ad4 commit e711e36
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion moodle/Util/MoodleUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public static function getMoodleComponent(File $file, $selfPath = true): ?string
$components = self::calculateAllComponents($moodleRoot);
// Have been unable to load components, done.
if (empty($components)) {
error_log("No components found");
return null;
}
}
Expand All @@ -249,8 +250,11 @@ public static function getMoodleComponent(File $file, $selfPath = true): ?string
if (empty($componentPath)) {
continue;
}

$componentPath = str_replace('\\', '/', $componentPath . DIRECTORY_SEPARATOR);

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

0 comments on commit e711e36

Please sign in to comment.