Moodle PHP Documentation 4.1
Moodle 4.1.19+ (Build: 20250711) (5f47dc23ffc)
Box\Spout\Writer\XLSX\Helper\FileSystemHelper Class Reference
Inheritance diagram for Box\Spout\Writer\XLSX\Helper\FileSystemHelper:
Box\Spout\Common\Helper\FileSystemHelper Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface Box\Spout\Common\Helper\FileSystemHelperInterface Box\Spout\Common\Helper\FileSystemHelperInterface

Public Member Functions

 __construct ($baseFolderPath, $zipHelper, $escaper)
 
 createBaseFilesAndFolders ()
 Creates all the folders needed to create a XLSX file, as well as the files that won't change.
 
 createContentTypesFile ($worksheets)
 Creates the "[Content_Types].xml" file under the root folder.
 
 createFileWithContents ($parentFolderPath, $fileName, $fileContents)
 Creates a file with the given name and content in the given folder.
 
 createFolder ($parentFolderPath, $folderName)
 Creates an empty folder with the given name under the given parent folder.
 
 createStylesFile ($styleManager)
 Creates the "styles.xml" file under the "xl" folder.
 
 createWorkbookFile ($worksheets)
 Creates the "workbook.xml" file under the "xl" folder.
 
 createWorkbookRelsFile ($worksheets)
 Creates the "workbook.xml.res" file under the "xl/_res" folder.
 
 deleteFile ($filePath)
 Delete the file at the given path.
 
 deleteFolderRecursively ($folderPath)
 Delete the folder at the given path as well as all its contents.
 
 getRootFolder ()
 
 getXlFolder ()
 
 getXlWorksheetsFolder ()
 
 zipRootFolderAndCopyToStream ($streamPointer)
 Zips the root folder and streams the contents of the zip into the given stream.
 

Public Attributes

const APP_NAME = 'Spout'
 
const APP_XML_FILE_NAME = 'app.xml'
 
const CONTENT_TYPES_XML_FILE_NAME = '[Content_Types].xml'
 
const CORE_XML_FILE_NAME = 'core.xml'
 
const DOC_PROPS_FOLDER_NAME = 'docProps'
 
const RELS_FILE_NAME = '.rels'
 
const RELS_FOLDER_NAME = '_rels'
 
const STYLES_XML_FILE_NAME = 'styles.xml'
 
const WORKBOOK_RELS_XML_FILE_NAME = 'workbook.xml.rels'
 
const WORKBOOK_XML_FILE_NAME = 'workbook.xml'
 
const WORKSHEETS_FOLDER_NAME = 'worksheets'
 
const XL_FOLDER_NAME = 'xl'
 

Protected Member Functions

 throwIfOperationNotInBaseFolder (string $operationFolderPath)
 All I/O operations must occur inside the base folder, for security reasons.
 

Protected Attributes

string $baseFolderRealPath
 Real path of the base folder where all the I/O can occur.
 

Constructor & Destructor Documentation

◆ __construct()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::__construct ( $baseFolderPath,
$zipHelper,
$escaper )
Parameters
string$baseFolderPathThe path of the base folder where all the I/O can occur
ZipHelper$zipHelperHelper to perform tasks with Zip archive
Box\Spout\Common\Helper\Escaper\XLSX$escaperUsed to escape XML data

Member Function Documentation

◆ createBaseFilesAndFolders()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::createBaseFilesAndFolders ( )

Creates all the folders needed to create a XLSX file, as well as the files that won't change.

Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create at least one of the base folders
Return values
void

Implements Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface.

◆ createContentTypesFile()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::createContentTypesFile ( $worksheets)

Creates the "[Content_Types].xml" file under the root folder.

Parameters
Worksheet[]$worksheets
Return values
FileSystemHelper

◆ createFileWithContents()

Box\Spout\Common\Helper\FileSystemHelper::createFileWithContents ( $parentFolderPath,
$fileName,
$fileContents )
inherited

Creates a file with the given name and content in the given folder.

The parent folder must exist.

Parameters
string$parentFolderPathThe parent folder path where the file is going to be created
string$fileNameThe name of the file to create
string$fileContentsThe contents of the file to create
Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the file or if the file path is not inside of the base folder
Return values
stringPath of the created file

Implements Box\Spout\Common\Helper\FileSystemHelperInterface.

◆ createFolder()

Box\Spout\Common\Helper\FileSystemHelper::createFolder ( $parentFolderPath,
$folderName )
inherited

Creates an empty folder with the given name under the given parent folder.

Parameters
string$parentFolderPathThe parent folder path under which the folder is going to be created
string$folderNameThe name of the folder to create
Exceptions
Box\Spout\Common\Exception\IOExceptionIf unable to create the folder or if the folder path is not inside of the base folder
Return values
stringPath of the created folder

Implements Box\Spout\Common\Helper\FileSystemHelperInterface.

◆ createStylesFile()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::createStylesFile ( $styleManager)

Creates the "styles.xml" file under the "xl" folder.

Parameters
StyleManager$styleManager
Return values
FileSystemHelper

◆ createWorkbookFile()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::createWorkbookFile ( $worksheets)

Creates the "workbook.xml" file under the "xl" folder.

Parameters
Worksheet[]$worksheets
Return values
FileSystemHelper

◆ createWorkbookRelsFile()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::createWorkbookRelsFile ( $worksheets)

Creates the "workbook.xml.res" file under the "xl/_res" folder.

Parameters
Worksheet[]$worksheets
Return values
FileSystemHelper

◆ deleteFile()

Box\Spout\Common\Helper\FileSystemHelper::deleteFile ( $filePath)
inherited

Delete the file at the given path.

Parameters
string$filePathPath of the file to delete
Exceptions
Box\Spout\Common\Exception\IOExceptionIf the file path is not inside of the base folder
Return values
void

Implements Box\Spout\Common\Helper\FileSystemHelperInterface.

◆ deleteFolderRecursively()

Box\Spout\Common\Helper\FileSystemHelper::deleteFolderRecursively ( $folderPath)
inherited

Delete the folder at the given path as well as all its contents.

Parameters
string$folderPathPath of the folder to delete
Exceptions
Box\Spout\Common\Exception\IOExceptionIf the folder path is not inside of the base folder
Return values
void

Implements Box\Spout\Common\Helper\FileSystemHelperInterface.

◆ getRootFolder()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::getRootFolder ( )

◆ getXlFolder()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::getXlFolder ( )
Return values
string

◆ getXlWorksheetsFolder()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::getXlWorksheetsFolder ( )
Return values
string

◆ throwIfOperationNotInBaseFolder()

Box\Spout\Common\Helper\FileSystemHelper::throwIfOperationNotInBaseFolder ( string $operationFolderPath)
protectedinherited

All I/O operations must occur inside the base folder, for security reasons.

This function will throw an exception if the folder where the I/O operation should occur is not inside the base folder.

Parameters
string$operationFolderPathThe path of the folder where the I/O operation should occur
Exceptions
Box\Spout\Common\Exception\IOExceptionIf the folder where the I/O operation should occur is not inside the base folder or the base folder does not exist
Return values
void

◆ zipRootFolderAndCopyToStream()

Box\Spout\Writer\XLSX\Helper\FileSystemHelper::zipRootFolderAndCopyToStream ( $streamPointer)

Zips the root folder and streams the contents of the zip into the given stream.

Parameters
resource$streamPointerPointer to the stream to copy the zip
Return values
void

The documentation for this class was generated from the following file: