Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Class: FileSystemHelper  - X-Ref


__construct(string $baseFolderPath, ZipHelper $zipHelper, XLSX $escaper)   X-Ref

param: string    $baseFolderPath The path of the base folder where all the I/O can occur
param: ZipHelper $zipHelper      Helper to perform tasks with Zip archive
param: XLSX      $escaper        Used to escape XML data

createFolder(string $parentFolderPath, string $folderName)   X-Ref
No description

createFileWithContents(string $parentFolderPath, string $fileName, string $fileContents)   X-Ref
No description

deleteFile(string $filePath)   X-Ref
No description

deleteFolderRecursively(string $folderPath)   X-Ref
No description

getRootFolder()   X-Ref
No description

getXlFolder()   X-Ref
No description

getXlWorksheetsFolder()   X-Ref
No description

getSheetsContentTempFolder()   X-Ref
No description

createBaseFilesAndFolders()   X-Ref
Creates all the folders needed to create a XLSX file, as well as the files that won't change.


createContentTypesFile(array $worksheets)   X-Ref
Creates the "[Content_Types].xml" file under the root folder.

param: Worksheet[] $worksheets

createWorkbookFile(array $worksheets)   X-Ref
Creates the "workbook.xml" file under the "xl" folder.

param: Worksheet[] $worksheets

createWorkbookRelsFile(array $worksheets)   X-Ref
Creates the "workbook.xml.res" file under the "xl/_res" folder.

param: Worksheet[] $worksheets

createWorksheetRelsFiles(array $worksheets)   X-Ref
Create the "rels" file for a given worksheet. This contains relations to the comments.xml and drawing.vml files for this worksheet.

param: Worksheet[] $worksheets

createStylesFile(StyleManager $styleManager)   X-Ref
Creates the "styles.xml" file under the "xl" folder.


createContentFiles(Options $options, array $worksheets)   X-Ref
Creates the "content.xml" file under the root folder.

param: Worksheet[] $worksheets

deleteWorksheetTempFolder()   X-Ref
Deletes the temporary folder where sheets content was stored.


zipRootFolderAndCopyToStream($streamPointer)   X-Ref
Zips the root folder and streams the contents of the zip into the given stream.

param: resource $streamPointer Pointer to the stream to copy the zip

getXMLFragmentForColumnWidths(Options $options, Sheet $sheet)   X-Ref
Construct column width references xml to inject into worksheet xml file.


getXMLFragmentForDefaultCellSizing(Options $options)   X-Ref
Constructs default row height and width xml to inject into worksheet xml file.


createRootFolder()   X-Ref
Creates the folder that will be used as root.


createRelsFolderAndFile()   X-Ref
Creates the "_rels" folder under the root folder as well as the ".rels" file in it.


createRelsFile()   X-Ref
Creates the ".rels" file under the "_rels" folder (under root).


createDocPropsFolderAndFiles()   X-Ref
Creates the "docProps" folder under the root folder as well as the "app.xml" and "core.xml" files in it.


createAppXmlFile()   X-Ref
Creates the "app.xml" file under the "docProps" folder.


createCoreXmlFile()   X-Ref
Creates the "core.xml" file under the "docProps" folder.


createXlFolderAndSubFolders()   X-Ref
Creates the "xl" folder under the root folder as well as its subfolders.


createSheetsContentTempFolder()   X-Ref
Creates the temp folder where specific sheets content will be written to.
This folder is not part of the final ODS file and is only used to be able to jump between sheets.


createXlRelsFolder()   X-Ref
Creates the "_rels" folder under the "xl" folder.


createDrawingsFolder()   X-Ref
Creates the "drawings" folder under the "xl" folder.


createXlWorksheetsFolder()   X-Ref
Creates the "worksheets" folder under the "xl" folder.


copyFileContentsToTarget(string $sourceFilePath, $targetResource)   X-Ref
Streams the content of the file at the given path into the target resource.
Depending on which mode the target resource was created with, it will truncate then copy
or append the content to the target file.

param: string   $sourceFilePath Path of the file whose content will be copied
param: resource $targetResource Target resource that will receive the content