From d5bbdee01f63ed79076db998c9d1a9a191bcdd48 Mon Sep 17 00:00:00 2001 From: Alexander Bias Date: Wed, 18 Sep 2024 21:01:37 +0200 Subject: [PATCH] Review changes --- classes/snippets.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/snippets.php b/classes/snippets.php index 3842ce90440..659f4678545 100644 --- a/classes/snippets.php +++ b/classes/snippets.php @@ -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) { @@ -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; }