Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
mod_data\local\importer\entries_importer Class Reference
Inheritance diagram for mod_data\local\importer\entries_importer:
mod_data\local\importer\csv_entries_importer

Public Member Functions

 __construct (string $importfilepath, string $importfilename)
 Creates an entries_importer object.
 
 get_data_file_content ()
 Returns the file content of the data file.
 
 get_file_content_from_zip (string $filename, string $zipsubdir='files/')
 Returns the file content from a file which has been stored in the zip archive.
 
 get_import_data_file_extension ()
 Return the file extension of the import data file which is being used, for example 'csv' for a csv entries_importer.
 

Protected Attributes

string string $importfilename
 The original name of the import file name including extension of the file which data should be imported from.
 
string string $importfilepath
 The import file path of the file which data should be imported from.
 
string string $importfiletype
 $importfiletype The file type of the import file.
 

Constructor & Destructor Documentation

◆ __construct()

mod_data\local\importer\entries_importer::__construct ( string $importfilepath,
string $importfilename )

Creates an entries_importer object.

This object can be used to import data from data files (like csv) and zip archives both including a data file and files to be stored in the course module context.

Parameters
string$importfilepaththe complete path of the import file including filename
string$importfilenamethe import file name as uploaded by the user
Exceptions
coding_exceptionif a wrong file type is being used

Member Function Documentation

◆ get_data_file_content()

mod_data\local\importer\entries_importer::get_data_file_content ( )

Returns the file content of the data file.

Returns the content of the file directly if the entries_importer's file is a data file itself. If the entries_importer's file is a zip archive, the content of the first found data file in the zip archive's root will be returned.

Return values
false|stringthe data file content as string; false, if file cannot be found/read

◆ get_file_content_from_zip()

mod_data\local\importer\entries_importer::get_file_content_from_zip ( string $filename,
string $zipsubdir = 'files/' )

Returns the file content from a file which has been stored in the zip archive.

Parameters
string$filename
string$zipsubdir
Return values
false|stringthe file content as string, false if the file could not be found/read

◆ get_import_data_file_extension()

mod_data\local\importer\entries_importer::get_import_data_file_extension ( )
abstract

Return the file extension of the import data file which is being used, for example 'csv' for a csv entries_importer.

Return values
stringthe file extension of the export data file

Reimplemented in mod_data\local\importer\csv_entries_importer.


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