Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
mod_data\local\importer\preset_importer Class Reference
Inheritance diagram for mod_data\local\importer\preset_importer:
mod_data\local\importer\preset_existing_importer mod_data\local\importer\preset_upload_importer

Public Member Functions

 __construct (manager $manager, string $directory)
 Constructor.
 
 cleanup ()
 Any clean up routines should go here.
 
 finish_import_process (bool $overwritesettings, stdClass $instance)
 Helper function to finish up the import routine.
 
 get_directory ()
 Returns the name of the directory the preset is located in.
 
 get_field_names (array $fields)
 Returns a list of the fields.
 
 get_file_contents (?\file_storage &$filestorage, ?\stored_file &$fileobj, ?string $dir, string $filename)
 Retreive the contents of a file.
 
 get_mapping_information ()
 Get the information needed to decide the modal.
 
 get_preset_selector ()
 Returns the information we need to build the importer selector.
 
 get_preset_settings ()
 Gets the preset settings.
 
 import (bool $overwritesettings)
 Import the preset into the given database module.
 
 needs_mapping ()
 Check if the importing process needs fields mapping.
 
 set_affected_fields (array $newfields=[], array $currentfields=[])
 Returns information about the fields needs to be removed, updated or created.
 

Static Public Member Functions

static create_from_parameters (manager $manager)
 Get the right importer instance from the provided parameters (POST or GET)
 
static create_from_plugin_or_directory (manager $manager, string $pluginordirectory)
 Get the right importer instance from the provided parameters (POST or GET)
 

Public Attributes

array $fieldstocreate
 fields to create.
 
array $fieldstoremove
 fields to remove.
 
array $fieldstoupdate
 fields to update.
 
array $settings
 settings to be imported.
 

Protected Attributes

string $directory
 directory where to find the preset.
 

Constructor & Destructor Documentation

◆ __construct()

mod_data\local\importer\preset_importer::__construct ( manager $manager,
string $directory )

Constructor.

Parameters
manager$manager
string$directory

Reimplemented in mod_data\local\importer\preset_existing_importer, and mod_data\local\importer\preset_upload_importer.

Member Function Documentation

◆ cleanup()

mod_data\local\importer\preset_importer::cleanup ( )

Any clean up routines should go here.

Return values
boolWether the preset has been successfully cleaned up.

Reimplemented in mod_data\local\importer\preset_upload_importer.

◆ create_from_parameters()

static mod_data\local\importer\preset_importer::create_from_parameters ( manager $manager)
static

Get the right importer instance from the provided parameters (POST or GET)

Parameters
manager$managerthe current database manager
Return values
preset_importerthe relevant preset_importer instance
Exceptions
moodle_exceptionwhen the file provided as parameter (POST or GET) does not exist

◆ create_from_plugin_or_directory()

static mod_data\local\importer\preset_importer::create_from_plugin_or_directory ( manager $manager,
string $pluginordirectory )
static

Get the right importer instance from the provided parameters (POST or GET)

Parameters
manager$managerthe current database manager
string$pluginordirectoryThe plugin name or directory to create the importer from.
Return values
preset_importerthe relevant preset_importer instance

◆ finish_import_process()

mod_data\local\importer\preset_importer::finish_import_process ( bool $overwritesettings,
stdClass $instance )

Helper function to finish up the import routine.

Called from fields and presets pages.

Parameters
bool$overwritesettingsWhether to overwrite activity settings or not.
stdClass$instancedatabase instance object
Return values
void

◆ get_directory()

mod_data\local\importer\preset_importer::get_directory ( )

Returns the name of the directory the preset is located in.

Return values
string

◆ get_field_names()

mod_data\local\importer\preset_importer::get_field_names ( array $fields)

Returns a list of the fields.

Parameters
array$fieldsArray of fields to get name from.
Return values
stringA string listing the names of the fields.

◆ get_file_contents()

mod_data\local\importer\preset_importer::get_file_contents ( ?\file_storage & $filestorage,
?\stored_file & $fileobj,
?string $dir,
string $filename )

Retreive the contents of a file.

That file may either be in a conventional directory of the Moodle file storage

Parameters
file_storage | null$filestorage. Should be null if using a conventional directory
stored_file | null$fileobjthe directory to look in. null if using a conventional directory
string | null$dirthe directory to look in. null if using the Moodle file storage
string$filenamethe name of the file we want
Return values
string|nullthe contents of the file or null if the file doesn't exist.

◆ get_mapping_information()

mod_data\local\importer\preset_importer::get_mapping_information ( )

Get the information needed to decide the modal.

Return values
arrayAn array with all the information to decide the mapping

◆ get_preset_selector()

mod_data\local\importer\preset_importer::get_preset_selector ( )

Returns the information we need to build the importer selector.

Return values
arrayValue and name for the preset importer selector

Reimplemented in mod_data\local\importer\preset_existing_importer.

◆ get_preset_settings()

mod_data\local\importer\preset_importer::get_preset_settings ( )

Gets the preset settings.

Return values
stdClassSettings to be imported.

◆ import()

mod_data\local\importer\preset_importer::import ( bool $overwritesettings)

Import the preset into the given database module.

Parameters
bool$overwritesettingsWhether to overwrite activity settings or not.
Return values
boolWether the importing has been successful.

◆ needs_mapping()

mod_data\local\importer\preset_importer::needs_mapping ( )

Check if the importing process needs fields mapping.

Return values
boolTrue if the current database needs to map the fields imported.

◆ set_affected_fields()

mod_data\local\importer\preset_importer::set_affected_fields ( array $newfields = [],
array $currentfields = [] )

Returns information about the fields needs to be removed, updated or created.

Parameters
array$newfieldsArray of new fields to be applied.
array$currentfieldsArray of current fields on database activity.
Return values
void

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