Skip to content

Creating A New Module

padams edited this page Jan 28, 2015 · 1 revision

OWA's functionality is completely modular. Developers can easily extend OWA by creating new modules. All modules are contained in the /path/to/owa/modules directory. The following is a tutorial on how to create a new module.

Getting Started

The high level sets involved in creating a module are:

Module Directory Structure

A module and it's associated files are stored in its own directory within OWA's module folder. The directory layout of a module is as follows:

'''/path/to/owa/modules/your_module''' This is the base directory for your module.

'''/path/to/owa/modules/your_module/classes''' This is where you should store helper classes. These classes can be loaded by using owa_coreAPI::supportClassFactory method.

'''/path/to/owa/modules/your_module/entities''' This is where entities classes should be stored. Controllers can access these entities using the owa_coreAPI::entitiyFactory method.

'''/path/to/owa/modules/your_module/handlers''' This is where events classes are stored.

'''/path/to/owa/modules/your_module/metrics''' This is where metrics classes are stored.

'''/path/to/owa/modules/your_module/updates''' This is where database schema updater classes are stored.


Once you have created a directory of your module, you need ot create a file in that directory called module.php. This file will contain the main module class that you can use to extend OWA. Your module.php file will contain all of the registrations for end handlers, entities, filters, and API commands that you wish to add to OWA. In module.php you need to define a class that inherits the abstract owa_module class and set a few properties like so:

class owa_helloModule extends owa_module {
	function __construct() {
		$this->name = 'hello'; // a string name for your module. no spaces.
		$this->display_name = 'Hello World'; // display name of the module
		$this->group = 'hello'; // module group. should be the same as your string name.
		$this->author = 'Joe Smith'; // authors name
		$this->version = '1.0'; // the version of your module
		$this->description = 'Hello world sample module.'; // short description
		$this->config_required = false; // is config required after activating he module
		$this->required_schema_version = 1; // the required schema version for entities that are registered by your module.
		return parent::__construct();

The class name for your module must conform to the ''nameModule'' naming convention.

Controllers & Views

Creating A New Report

Event Handlers

Creating Entities

Entities are the core objects in OWA that need to be accessed, related, or persisted between requests or sessions. Entities that persist to a database have their own corresponding database table. Entities are self contained objects that provide all the methods needed to create, alter and destroy themselves, as well as getting and setting of their properties.

Entity classes inherit a number of common methods from owa_entitiy.php and must be stored in a module's ''entities'' sub directory.

See the entities page for more info on how to create entities.

Once an entity is created it must be registered with in your module's module.php using the registerEntity method in order for it's database tables to be created during install.

Once an entitiy is created, registered and installed, it can accessed via OWA's owa_coreAPI::entitiyFactory method.

You can’t perform that action at this time.