Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abias committed Sep 18, 2024
1 parent 3915701 commit d5bbdee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions classes/snippets.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static function get_snippet_file($path, $source): string|null {
public static function get_builtin_snippet_preview_url($path, $source) {
global $CFG;

// Replace the .scss suffix with a .png suffix in the path.
// Search for the .scss suffix in the path.
$search = '.scss';
$pos = strrpos($path, $search);
if ($pos !== false) {
Expand All @@ -127,10 +127,12 @@ public static function get_builtin_snippet_preview_url($path, $source) {
$file = $files[0];
// Compose the files URL.
$url = new \moodle_url(substr($file, strlen($CFG->dirroot)));
// And check if the file is readable.
return is_readable($file) ? $url : null;
}
}
// If anything wen't wrong return null, just as if no snippet preview is present.

// If anything went wrong, return null just as if no snippet preview is present.
return null;
}

Expand Down

0 comments on commit d5bbdee

Please sign in to comment.