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

Public Member Functions

 get_added_records_messages ()
 Getter for the array of messages for added records.
 
 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 ()
 Declares the entries_importer to use a csv file as data file.
 
 import_csv (stdClass $cm, stdClass $data, string $encoding, string $fielddelimiter)
 Import records for a data instance from csv data.
 

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.
 

Member Function Documentation

◆ get_added_records_messages()

mod_data\local\importer\csv_entries_importer::get_added_records_messages ( )

Getter for the array of messages for added records.

For each successfully added record the array contains a log message.

Return values
arrayArray of message strings: For each added record one message string

◆ get_data_file_content()

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

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/' )
inherited

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\csv_entries_importer::get_import_data_file_extension ( )

Declares the entries_importer to use a csv file as data file.

See also
entries_importer\get_import_data_file_extension()

Reimplemented from mod_data\local\importer\entries_importer.

◆ import_csv()

mod_data\local\importer\csv_entries_importer::import_csv ( stdClass $cm,
stdClass $data,
string $encoding,
string $fielddelimiter )

Import records for a data instance from csv data.

Parameters
stdClass$cmCourse module of the data instance.
stdClass$dataThe data instance.
string$encodingThe encoding of csv data.
string$fielddelimiterThe delimiter of the csv data.
Exceptions
moodle_exception

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