From 264a575c3d747919d2a4bd7ba49810ddcbe0a496 Mon Sep 17 00:00:00 2001 From: Nihaal Shaikh Date: Tue, 10 Sep 2024 10:18:01 +0200 Subject: [PATCH] Update #86by49k22 - code reformatted and moodle code style followed --- lib.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib.php b/lib.php index 3470957..f839fae 100644 --- a/lib.php +++ b/lib.php @@ -34,12 +34,9 @@ * @param array $args * @param bool $forcedownload * @param array $options - * - * @throws coding_exception - * @throws moodle_exception - * @throws require_login_exception */ -function block_fastnav_pluginfile($course, $recordorcm, $context, $filearea, $args, $forcedownload, array $options = []) { +function block_fastnav_pluginfile(stdClass $course, $recordorcm, stdClass $context, string $filearea, array $args, $forcedownload, + array $options = []): void { global $CFG; if ($context->contextlevel !== CONTEXT_BLOCK) { @@ -57,21 +54,28 @@ function block_fastnav_pluginfile($course, $recordorcm, $context, $filearea, $ar $parentcontext = $context->get_parent_context(); // Check if category is visible and user can view this category. if (($parentcontext->contextlevel === CONTEXT_COURSECAT) - && !core_course_category::get($parentcontext->instanceid, IGNORE_MISSING)) { + && !core_course_category::get(id: $parentcontext->instanceid, strictness: IGNORE_MISSING)) { send_file_not_found(); } } $fs = get_file_storage(); - $itemid = (int) array_shift($args); - $filename = array_pop($args); + $itemid = (int) array_shift(array: $args); + $filename = array_pop(array: $args); - $file = $fs->get_file($context->id, 'block_fastnav', $filearea, $itemid, '/', $filename); + $file = $fs->get_file( + contextid: $context->id, + component: 'block_fastnav', + filearea: $filearea, + itemid: $itemid, + filepath: '/', + filename: $filename + ); if (!$file || $file->is_directory()) { send_file_not_found(); } \core\session\manager::write_close(); - send_stored_file($file, null, 0, true, $options); + send_stored_file(storedfile: $file, forcedownload: true, options: $options); }