Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
moodle1_file_manager Class Reference

The class responsible for files migration. More...

Inheritance diagram for moodle1_file_manager:

Public Member Functions

 __construct (moodle1_converter $converter, $contextid=null, $component=null, $filearea=null, $itemid=0, $userid=null)
 Constructor optionally accepting some default values for the migrated files.
 
 get_fileids ()
 Returns the list of all file ids migrated by this instance so far.
 
 log ($message, $level, $a=null, $depth=null, $display=false)
 This function will be responsible for handling the params, and to call to the corresponding logger->process() once all modifications in params have been performed.
 
 migrate_directory ($rootpath, $relpath='/')
 
 migrate_file ($sourcepath, $filepath='/', $filename=null, $sortorder=0, $timecreated=null, $timemodified=null)
 
 reset_fileids ()
 Explicitly clear the list of file ids migrated by this instance so far.
 

Public Attributes

string $component
 component name of the files being migrated
 
int $contextid
 context id of the files being migrated
 
moodle1_converter $converter
 instance we serve to
 
string $filearea
 file area of the files being migrated
 
int $itemid = 0
 item id of the files being migrated
 
int $userid
 user id
 

Protected Member Functions

 add_file_to_pool ($pathname)
 Copies the given file to the pool directory.
 
 make_file_record (array $fileinfo)
 internal implementation details ////////////////////////////////////////
 
 stash_file (array $filerecord)
 Stashes the file record into 'files' stash and adds the record id to list of migrated files.
 

Protected Attributes

string $basepath
 the root of the converter temp directory
 
array $fileids = array()
 of file ids that were migrated by this instance
 

Detailed Description

The class responsible for files migration.

The files in Moodle 1.9 backup are stored in moddata, user_files, group_files, course_files and site_files folders.

Constructor & Destructor Documentation

◆ __construct()

moodle1_file_manager::__construct ( moodle1_converter $converter,
$contextid = null,
$component = null,
$filearea = null,
$itemid = 0,
$userid = null )

Constructor optionally accepting some default values for the migrated files.

Parameters
moodle1_converter$converterthe converter instance we serve to
int$contextidinitial context id of the files being migrated
string$componentinitial component name of the files being migrated
string$fileareainitial file area of the files being migrated
int$itemidinitial item id of the files being migrated
int$useridinitial user id of the files being migrated

Member Function Documentation

◆ add_file_to_pool()

moodle1_file_manager::add_file_to_pool ( $pathname)
protected

Copies the given file to the pool directory.

Returns an array containing SHA1 hash of the file contents, the file size and a flag indicating whether the file was actually added to the pool or whether it was already there.

Parameters
string$pathnamethe full path to the file
Return values
arraywith keys (string)contenthash, (int)filesize, (bool)newfile

◆ get_fileids()

moodle1_file_manager::get_fileids ( )

Returns the list of all file ids migrated by this instance so far.

Return values
arrayof int

◆ log()

moodle1_file_manager::log ( $message,
$level,
$a = null,
$depth = null,
$display = false )

This function will be responsible for handling the params, and to call to the corresponding logger->process() once all modifications in params have been performed.

Implements loggable.

◆ make_file_record()

moodle1_file_manager::make_file_record ( array $fileinfo)
protected

internal implementation details ////////////////////////////////////////

Prepares a fake record from the files table

Parameters
array$fileinfoexplicit file data
Return values
array

◆ stash_file()

moodle1_file_manager::stash_file ( array $filerecord)
protected

Stashes the file record into 'files' stash and adds the record id to list of migrated files.

Parameters
array$filerecord

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