Search moodle.org's
Developer Documentation

See Release Notes

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

(no description)

File Size: 144 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

entries_importer:: (4 methods):
  __construct()
  get_data_file_content()
  get_file_content_from_zip()
  extract_zip()


Class: entries_importer  - X-Ref

Importer class for importing data and - if needed - files as well from a zip archive.

__construct(string $importfilepath, string $importfilename)   X-Ref
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.

param: string $importfilepath the complete path of the import file including filename
param: string $importfilename the import file name as uploaded by the user

get_data_file_content()   X-Ref
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: false|string the data file content as string; false, if file cannot be found/read

get_file_content_from_zip(string $filename, string $zipsubdir = 'files/')   X-Ref
Returns the file content from a file which has been stored in the zip archive.

param: string $filename
param: string $zipsubdir
return: false|string the file content as string, false if the file could not be found/read

extract_zip()   X-Ref
Extracts (if not already done and if we have a zip file to deal with) the zip file to a temporary directory.

return: void