in classes/api/base.php [926:952]
protected function get_file_contents($path, $filename, $contextid) {
// Get file contents.
$fs = get_file_storage();
// Prepare file record object.
$fileinfo = [
'component' => 'mod_assign', // Usually = table name.
'filearea' => 'intro', // Usually = table name.
'itemid' => 0, // Usually = ID of row in table.
'contextid' => $contextid, // ID of context.
'filepath' => $path, // Any path beginning and ending in /.
'filename' => $filename
];
// Get file.
$file = $fs->get_file($fileinfo['contextid'], $fileinfo['component'], $fileinfo['filearea'], $fileinfo['itemid'],
$fileinfo['filepath'], $fileinfo['filename']);
$contents = array();
if ($file) {
$contents['filename'] = $file->get_filename();
$contents['content'] = $file->get_content();
}
return $contents;
}