You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This document describes how to implement Modules. A Module allows packages and services to be created. They define the fields requested when adding or editing packages and services, as well as handle all communication with remote servers to provision said packages and services.

Getting Started with Modules

For the purpose of this manual, the module name we'll refer to is my_module. Your module name will, of course, differ.

Module names must be unique

A user will not be able to install two module with the same name.

File Structure

Modules are fully contained within their named module directory and placed in the /installpath/components/modules/ directory. Each module is only required to contain a single class, representing the module, but the following is the recommended structure:

  • /modules/
    • my_module/
      • views/
      • language/
      • my_module.php

Install Logic

If your module requires any code to execute when installed, place that logic in your module's install() method.

/modules/my_module/my_module.php
<?php
class MyModule extends Module {

    ...

    public function install() {
        #
        # TODO: Place installation logic here
        #
    }
}
?>

Uninstall Logic

If your module required code to install, it likely requires code to uninstall. Place that logic in your module's uninstall() method.

There are two parameters passed to the uninstall() method. The first ($module_id) is the ID of the module being uninstalled. Because a module can be installed independently under different companies you may need to perform uninstall logic for a single module instance. The second parameter ($last_instance) identifies whether or not this is the last instance of this module in the system. If true, be sure to remove any remaining remnants of the module.

/modules/my_module/my_module.php
<?php 
class MyModule extends Module {

    ... 

    public function uninstall($module_id, $last_instance) {
        #
        # TODO: Place uninstallation logic here 
        #
    } 
} 
?>
  • No labels