Synchronisation settings

Storing and retrieving settings will need to be managed by the framework_importer class. We can implement a new function that attempts to load settings from our new database table and, if it fails to do so, stores a set of defaults (so-called "lazy" loading). The following is the init() function in its entirety:

function init() {       global $DB;       // Get details of external database from our config. Currently we       do this one record at a time, which is a little clunky:       $records = $DB->get_records('tool_lpsync', null, null);       // if there aren't any entries in the table then we need to       prepare them:       if(count($records) == 0)       {             $rows = array(  'type' => 'mysqli',                              'host' => 'localhost',                              'user' => '',  'pass' => '',  ...

Get Moodle 3.x Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.