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

Compare with Current View Page History

Version 1 Next »

 

Required Methods

The following methods are required to be implemented for each module, and a description of each.

getName()

The getName() method simply returns the name of the method. It's always best to define any language in your module using language files (see Translating Blesta for more information).

class MyModule extends Module {
...
	public function getName() {
		return Language::_("MyModule.name", true);
	}
...
}

getVersion()

This method must return the current version number of the module. Upon installation or upgrade, Blesta records the current code version so that it can tell when an upgrade/downgrade is available. The version number should be compatible with PHP's version_compare() function.

class MyModule extends Module {
	const VERSION = "1.0.0";	
...
	public function getVersion() {
		return self::VERSION;
	}
...

}

getAuthors()

This method returns an array containing information about the authors of the module.

class MyModule extends Module {
    private static $authors = array(array('name' => "Phillips Data, Inc.", 'url' =>"http://www.blesta.com"));
...
	public function getAuthors() {
		return self::$authors;
	}
...
}

getServiceName($service)

Given a particular service, this method should return the label used to identify the service. For example, if the module were representing VOIP services, the value returned by this method might be the phone number associated with the VOIP service.

class MyModule extends Module {
...
	public function getServiceName($service) {
		$key = "phone_number";
        foreach ($service->fields as $field) {
            if ($field->key == $key)
                return $field->value;
        }
        return null;
	}
...
}

moduleRowName()

The moduleRowName() method returns the value used to represent a module row. For example, if the module were representing shared hosting services and each module row were a physical server the value returned by this method might be "Server".

class MyModule extends Module {
...
	public function moduleRowName() {
		return Language::_("MyModule.module_row", true);
	}
...
}

moduleRowNamePlural()

A plural representation of the moduleRowName() method (e.g. "Servers").

class MyModule extends Module {
...
	public function moduleRowNamePlural() {
		return Language::_("MyModule.module_row_plural", true);
	}
...
}

moduleRowMetaKey()

 

Optional Methods

  • No labels