Introduction plugin types in Moodle/Totara
As we know, Moodle/Totara has multiple plugin types. To extend core functionality, different ways are used to create each plugin type.
Some of the plugin types are:
- local etc.
If you want to create a new plugin type, then you have to make a change in the core file
In this example, we will create a plugin type named “courseavailabiliy”. To create it, we have to make two changes in the above-listed file.
- Firstly, we create the “courseavailability” folder in the root folder of your Totara.
- Now, add below line at the end of “fetch_subsystems()” function:
‘courseavailability’ => $CFG->dirroot . ‘/courseavailability’;
- After that, please paste the below line at the end of the “fetch_plugintypes()” function:
‘courseavailability’ => $CFG->dirroot . ‘/courseavailability/’;
By calling this function, you can get a list of available plugin types together with their location.
- If you want to use your own language strings, then you need to create a plugin type file under this “lang/en/”. You need to name this file the same plugin type name. In our example, we have created a “courseavailability” so my language file name is “courseavailability.php”.
- Now, you have to create a plugin info class for this plugin type. As we know, a plugin info class describes the properties of your plugins like plugin settings, plugin status, and plugin actions(install, uninstall).
You have to place this file in “/lib/classes/pluginginfo”. This filename will be the same as the plugin type name. In our example, we create “courseavailability.php”.
“fetch_subsystems()” returns a list of core subsystems. Subsystems in Moodle don’t seem to be plugins themselves. These are groups of related functions and classes that are part of the core but are logically grouped together. They can be referred to using core_xxx where xxx is the subsystem name.
Note: If you want to create the new plugin of this new one, then you have to place your plugin into the ‘/courseavailability/’ directory.